tree data BUGFIX wrong vars used
diff --git a/src/tree_data.c b/src/tree_data.c
index 5d2d490..e90aa7c 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1385,8 +1385,8 @@
                 for (const struct lysc_node *key = lysc_node_child(node1->schema);
                         key && (key->flags & LYS_KEY);
                         key = key->next) {
-                    if (!node1 || !node2) {
-                        return (node1 == node2) ? LY_SUCCESS : LY_ENOT;
+                    if (!iter1 || !iter2) {
+                        return (iter1 == iter2) ? LY_SUCCESS : LY_ENOT;
                     }
                     r = lyd_compare_single_schema(iter1, iter2, options, 1);
                     LY_CHECK_RET(r);