validation NEW default values creation

Also a lot of other refactoring and
improvements. No tests yet.
diff --git a/src/validation.h b/src/validation.h
index 8c665d7..dfc81d0 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -34,17 +34,45 @@
                           ly_clb_resolve_prefix get_prefix_clb, void *parser_data, const struct lyd_node **trees);
 
 /**
- * @brief Perform all vaidation tasks that depend on other nodes, the data tree must
- * be complete when calling this function.
+ * @brief Perform all validation tasks, the data tree must be complete when calling this function.
  *
  * @param[in] trees Array of all data trees.
  * @param[in] modules Array of modules that should be validated, NULL for all modules.
  * @param[in] mod_count Modules count.
  * @param[in] ctx Context if all modules should be validated, NULL for only selected modules.
- * @param[in] options Validation options.
+ * @param[in] val_opts Validation options.
  * @return LY_ERR value.
  */
 LY_ERR lyd_validate_data(const struct lyd_node **trees, const struct lys_module **modules, int mod_count,
-                         struct ly_ctx *ctx, int options);
+                         struct ly_ctx *ctx, int val_opts);
+
+/**
+ * @brief Check the existence and create any non-existing default siblings, recursively for the created nodes.
+ *
+ * @param[in] parent Parent of the potential default values.
+ * @param[in,out] first First sibling.
+ * @param[in] schema Schema parent of the default values, NULL for top-level siblings.
+ * @param[in] mod Module of the default values, NULL for nested (non top-level) siblings.
+ * @param[in] node_types Set to add nodes with unresolved types into.
+ * @param[in] node_when Set to add nodes with "when" conditions into.
+ * @return LY_ERR value.
+ */
+LY_ERR lyd_validate_defaults_r(struct lyd_node_inner *parent, struct lyd_node **first, const struct lysc_node *schema,
+                               const struct lysc_module *mod, struct ly_set *node_types, struct ly_set *node_when);
+
+/**
+ * @brief Check the existence and create any non-existing default top-level nodes.
+ *
+ * @param[in,out] first First top-level sibling. There may be no explicit nodes.
+ * @param[in] modules Array of modules that should be considered, NULL for all modules.
+ * @param[in] mod_count Modules count.
+ * @param[in] ctx Context if all modules should be considered, NULL for only selected modules.
+ * @param[in] node_types Set to add nodes with unresolved types into, can be NULL if not needed.
+ * @param[in] node_when Set to add nodes with "when" conditions into, can be NULL if not needed.
+ * @param[in] val_opts Relevant validation options (#LYD_VALOPT_DATA_ONLY).
+ * @return LY_ERR value.
+ */
+LY_ERR lyd_validate_defaults_top(struct lyd_node **first, const struct lys_module **modules, int mod_count,
+                                 struct ly_ctx *ctx, struct ly_set *node_types, struct ly_set *node_when, int val_opts);
 
 #endif /* LY_VALIDATION_H_ */