tree data BUGFIX inserting nodes before opaq nodes
diff --git a/src/tree_data.c b/src/tree_data.c
index 0fdf662..5676da8 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -672,7 +672,7 @@
anchor = lyd_insert_get_next_anchor(first_sibling, node);
/* cannot insert data node after opaque nodes */
- if (node->schema && first_sibling && !first_sibling->prev->schema) {
+ if (!anchor && node->schema && first_sibling && !first_sibling->prev->schema) {
anchor = first_sibling->prev;
while ((anchor != first_sibling) && !anchor->prev->schema) {
anchor = anchor->prev;