data tree FEATURE with-defaults support

add lyd_wd_add() to add default nodes.
diff --git a/src/tree_data.h b/src/tree_data.h
index d7aed28..c7d660e 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -222,6 +222,10 @@
  * subtree filter data, edit-config's data or other type of data set - such data do not represent a complete data set
  * and some of the validation rules can fail. Therefore there are other options (within lower 8 bits) to make parser
  * to accept such a data.
+ * - for validation, parser needs to add default nodes into the data tree. By default, these additional (implicit)
+ * nodes are removed before the parser returns. However, if caller use one of the LYD_WD_* option, the default nodes
+ * added by parser are kept in the resulting tree or even the explicit nodes with the default values can be removed
+ * (in case of #LYD_WD_TRIM option).
  * @{
  */
 
@@ -275,6 +279,19 @@
                                        If used, libyang generates validation error instead of silently removing the
                                        constrained subtree. */
 
+#define LYD_WD_MASK       0xF0000 /**< Mask for with-defaults modes */
+#define LYD_WD_TRIM       0x10000 /**< Remove all nodes with the value equal to their default value */
+#define LYD_WD_ALL        0x20000 /**< Explicitly add all missing nodes with their default value */
+#define LYD_WD_ALL_TAG    0x40000 /**< Same as LYD_WD_ALL but also adds attribute 'default' with value 'true' to
+                                       all nodes that has its default value. The 'default' attribute has namespace:
+                                       urn:ietf:params:xml:ns:netconf:default:1.0 and thus the attributes are
+                                       created only when the ietf-netconf-with-defaults module is present in libyang
+                                       context. */
+#define LYD_WD_IMPL_TAG   0x80000 /**< Same as LYD_WD_ALL_TAG but the attributes are added only to the nodes that
+                                       are being created and were not part of the original data tree despite their
+                                       value is equal to their default value. There is the same limitation regarding
+                                       the presence of ietf-netconf-with-defaults module in libyang context. */
+
 /**@} parseroptions */
 
 /**
@@ -581,6 +598,26 @@
 int lyd_validate(struct lyd_node **node, int options, ...);
 
 /**
+ * @brief Add default nodes into the data tree.
+ *
+ * @param[in] ctx Optional parameter. If provided, default nodes from all modules in the context will be added (so it
+ *            has no effect for #LYD_WD_TRIM). If NULL, only the modules explicitly mentioned in data tree are
+ *            taken into account.
+ * @param[in] root Data tree root. In case of #LYD_WD_TRIM the data tree can be modified so the root can be changed or
+ *            removed. In other modes and with empty data tree, new default nodes can be created so the root pointer
+ *            will contain/return the newly created data tree.
+ * @param[in] options Options for the inserting data to the target data tree options, see @ref parseroptions. The
+ *            LYD_WD_* options are used to select functionality:
+ * - #LYD_WD_TRIM - remove all nodes that have value equal to their default value
+ * - #LYD_WD_ALL - add default nodes
+ * - #LYD_WD_ALL_TAG - add default nodes and add attribute 'default' with value 'true' to all nodes having their default value
+ * - #LYD_WD_IMPL_TAG - add default nodes, but add attribute 'default' only to the added nodes
+ * @note The *_TAG modes require to have ietf-netconf-with-defaults module in the context of the data tree.
+ * @return EXIT_SUCCESS ot EXIT_FAILURE
+ */
+int lyd_wd_add(struct ly_ctx *ctx, struct lyd_node **root, int options);
+
+/**
  * @brief Unlink the specified data subtree. All referenced namespaces are copied.
  *
  * Note, that the node's connection with the schema tree is kept. Therefore, in case of