data tree BUGFIX check leafref links before merge destruct

Fixes #581
diff --git a/src/tree_data.c b/src/tree_data.c
index df61e59..d78e302 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -3038,6 +3038,13 @@
 
     /* process source according to options */
     if (options & LYD_OPT_DESTRUCT) {
+        LY_TREE_FOR(src, iter) {
+            check_leaf_list_backlinks((struct lyd_node *)iter, 2);
+            if (options & LYD_OPT_NOSIBLINGS) {
+                break;
+            }
+        }
+
         node = (struct lyd_node *)src;
         if ((node->prev != node) && (options & LYD_OPT_NOSIBLINGS)) {
             node2 = node->prev;