data tree BUGFIX insert opaque node handling
diff --git a/src/tree_data.c b/src/tree_data.c
index ef0330d..e799ff2 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -3251,7 +3251,8 @@
 
     LY_CHECK_ARG_RET(NULL, target, LY_EINVAL);
 
-    if (!siblings || (lysc_data_parent(siblings->schema) != lysc_data_parent(target->schema))) {
+    if (!siblings || (siblings->schema && target->schema &&
+            (lysc_data_parent(siblings->schema) != lysc_data_parent(target->schema)))) {
         /* no data or schema mismatch */
         if (match) {
             *match = NULL;
@@ -3269,7 +3270,7 @@
     }
 
     parent = (struct lyd_node_inner *)siblings->parent;
-    if (parent && parent->children_ht) {
+    if (parent && parent->schema && parent->children_ht) {
         assert(target->hash);
 
         /* find by hash */