tree data UPDATE lyd_find_sibling_* must ignore opaque nodes

They cannot be returned because hash search will
never find them so there would be a functional
difference when hashes are used and when not.
diff --git a/src/tree_data.c b/src/tree_data.c
index 72f9fd5..7cd608e 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -2655,7 +2655,7 @@
                     break;
                 }
             } else {
-                if (!lyd_compare_single(siblings, target, LYD_COMPARE_OPAQ)) {
+                if (!lyd_compare_single(siblings, target, 0)) {
                     break;
                 }
             }
@@ -2757,7 +2757,7 @@
     }
 
     /* set options */
-    comp_opts = LYD_COMPARE_OPAQ | (lysc_is_dup_inst_list(target->schema) ? LYD_COMPARE_FULL_RECURSION : 0);
+    comp_opts = (lysc_is_dup_inst_list(target->schema) ? LYD_COMPARE_FULL_RECURSION : 0);
 
     /* get first sibling */
     siblings = lyd_first_sibling(siblings);
diff --git a/src/tree_data_common.c b/src/tree_data_common.c
index b19ba3a..646d76b 100644
--- a/src/tree_data_common.c
+++ b/src/tree_data_common.c
@@ -1142,7 +1142,6 @@
 {
     struct lyd_node **match_p;
     struct lyd_node_inner *parent;
-    const struct lysc_node *cur_schema;
     uint32_t hash;
     lyht_value_equal_cb ht_cb;
 
@@ -1185,25 +1184,22 @@
             }
         }
 
-        /* search manually without hashes */
-        for ( ; siblings; siblings = siblings->next) {
-            cur_schema = lyd_node_schema(siblings);
-            if (!cur_schema) {
-                /* some unknown opaque node */
-                continue;
-            }
-
+        /* search manually without hashes and ignore opaque nodes (cannot be found by hashes) */
+        for ( ; siblings && siblings->schema; siblings = siblings->next) {
             /* schema match is enough */
-            if (cur_schema->module->ctx == schema->module->ctx) {
-                if (cur_schema == schema) {
+            if (LYD_CTX(siblings) == schema->module->ctx) {
+                if (siblings->schema == schema) {
                     break;
                 }
             } else {
-                if (!strcmp(cur_schema->name, schema->name) && !strcmp(cur_schema->module->name, schema->module->name)) {
+                if (!strcmp(LYD_NAME(siblings), schema->name) && !strcmp(siblings->schema->module->name, schema->module->name)) {
                     break;
                 }
             }
         }
+        if (siblings && !siblings->schema) {
+            siblings = NULL;
+        }
     }
 
     if (!siblings) {
diff --git a/src/xpath.c b/src/xpath.c
index 9a197ac..fcfec99 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -6172,6 +6172,10 @@
         } else {
             r = lyd_find_sibling_val(siblings, scnode, NULL, 0, &sub);
         }
+        if (r == LY_ENOTFOUND) {
+            /* may still be an opaque node */
+            r = lyd_find_sibling_opaq_next(siblings, scnode->name, &sub);
+        }
         LY_CHECK_ERR_GOTO(r && (r != LY_ENOTFOUND), ret = r, cleanup);
 
         /* when check */