data tree BUGFIX handle insert sibling matching params
diff --git a/src/tree_data.c b/src/tree_data.c
index 1db88a3..72f34d0 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -2016,6 +2016,11 @@
         LY_CHECK_RET(lyd_insert_check_schema(lysc_data_parent(sibling->schema), node->schema));
     }
 
+    if (sibling == node) {
+        /* we need to keep the connection to siblings so we can insert into them */
+        sibling = sibling->prev;
+    }
+
     if (node->parent || node->prev->next) {
         lyd_unlink_tree(node);
     }