xpath BUGFIX nested predicates in leaf-lists

Refs #1940
diff --git a/src/xpath.c b/src/xpath.c
index ffb572b..08e8110 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -7808,14 +7808,22 @@
         val_start_idx = e_idx;
 
         /* ']' */
-        while (lyxp_check_token(NULL, exp, e_idx, LYXP_TOKEN_BRACK2)) {
-            if (!lyxp_check_token(NULL, exp, e_idx, LYXP_TOKEN_OPER_LOG)) {
+        nested_pred = 1;
+        do {
+            ++e_idx;
+
+            if ((nested_pred == 1) && !lyxp_check_token(NULL, exp, e_idx, LYXP_TOKEN_OPER_LOG)) {
                 /* higher priority than '=' */
                 rc = LY_ENOT;
                 goto cleanup;
+            } else if (!lyxp_check_token(NULL, exp, e_idx, LYXP_TOKEN_BRACK1)) {
+                /* nested predicate */
+                ++nested_pred;
+            } else if (!lyxp_check_token(NULL, exp, e_idx, LYXP_TOKEN_BRACK2)) {
+                /* predicate end */
+                --nested_pred;
             }
-            ++e_idx;
-        }
+        } while (nested_pred);
 
         /* try to evaluate the value */
         LY_CHECK_GOTO(rc = eval_name_test_try_compile_predicate_append(exp, val_start_idx, e_idx - 1, ctx_scnode, set,