data tree BUGFIX opaque node handling
diff --git a/src/tree_data.c b/src/tree_data.c
index 9a21996..a1acddc 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -3298,7 +3298,7 @@
     assert(siblings && schema);
 
     parent = (struct lyd_node_inner *)siblings->parent;
-    if (parent && parent->children_ht) {
+    if (parent && parent->schema && parent->children_ht) {
         /* calculate our hash */
         hash = dict_hash_multi(0, schema->module->name, strlen(schema->module->name));
         hash = dict_hash_multi(hash, schema->name, strlen(schema->name));
@@ -3358,7 +3358,7 @@
 
     LY_CHECK_ARG_RET(NULL, schema, !(schema->nodetype & (LYS_CHOICE | LYS_CASE)), LY_EINVAL);
 
-    if (!siblings || (lysc_data_parent(siblings->schema) != lysc_data_parent(schema))) {
+    if (!siblings || (siblings->schema && (lysc_data_parent(siblings->schema) != lysc_data_parent(schema)))) {
         /* no data or schema mismatch */
         if (match) {
             *match = NULL;