tree data FEATURE dup option not to duplicate ext nodes
diff --git a/src/tree_data.c b/src/tree_data.c
index 46668a7..eee87c8 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1562,6 +1562,11 @@
     LY_CHECK_ARG_RET(NULL, node, LY_EINVAL);
 
     if (node->flags & LYD_EXT) {
+        if (options & LYD_DUP_NO_EXT) {
+            /* no not duplicate this subtree */
+            return LY_SUCCESS;
+        }
+
         /* we need to use the same context */
         trg_ctx = LYD_CTX(node);
     }