data tree NEW lyd_dup_withsiblings()
Always safer to use than lyd_dup().
Refs #479
diff --git a/src/tree_data.h b/src/tree_data.h
index dc8cceb..4ea4f2e 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -822,7 +822,9 @@
unsigned int lyd_list_pos(const struct lyd_node *node);
/**
- * @brief Create a copy of the specified data tree \p node. Schema references are kept the same.
+ * @brief Create a copy of the specified data tree \p node. Schema references are kept the same. Use carefully,
+ * since libyang silently creates default nodes, it is always better to use lyd_dup_withsiblings() to duplicate
+ * the complete data tree.
*
* __PARTIAL CHANGE__ - validate after the final change on the data tree (see @ref howtodatamanipulators).
*
@@ -833,6 +835,18 @@
struct lyd_node *lyd_dup(const struct lyd_node *node, int recursive);
/**
+ * @brief Create a copy of the specified data tree and all its siblings (preceding as well as following).
+ * Schema references are kept the same.
+ *
+ * __PARTIAL CHANGE__ - validate after the final change on the data tree (see @ref howtodatamanipulators).
+ *
+ * @param[in] node Data tree sibling node to be duplicated.
+ * @param[in] recursive 1 if all children of all the siblings are supposed to be also duplicated.
+ * @return Created copy of the provided data \p node and all of its siblings.
+ */
+struct lyd_node *lyd_dup_withsiblings(const struct lyd_node *node, int recursive);
+
+/**
* @brief Create a copy of the specified data tree \p node in the different context. All the
* schema references and strings are re-mapped into the specified context.
*