tree data helpers BUGFIX unknown top-level opaque node
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index 754bc55..97db00f 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -584,11 +584,14 @@
         } else {
             /* get module */
             mod = lyd_owner_module(iter);
+            if (!mod && !schema) {
+                /* top-level opaque node has unknown module */
+                break;
+            }
 
             /* get schema node */
             schema = lys_find_child(schema, mod ? mod : schema->module, LYD_NAME(iter), 0, 0, 0);
         }
-
     } while (schema && (iter != node));
 
     return schema;