diff --git a/CMakeLists.txt b/CMakeLists.txt
index a5f7661..19dbde8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -116,8 +116,9 @@
     src/json.c
     src/tree_data.c
     src/tree_data_free.c
-    src/tree_data_helpers.c
+    src/tree_data_common.c
     src/tree_data_hash.c
+    src/tree_data_new.c
     src/parser_xml.c
     src/parser_json.c
     src/parser_lyb.c
@@ -132,12 +133,12 @@
     src/schema_features.c
     src/tree_schema.c
     src/tree_schema_free.c
-    src/tree_schema_helpers.c
+    src/tree_schema_common.c
     src/in.c
     src/lyb.c
+    src/parser_common.c
     src/parser_yang.c
     src/parser_yin.c
-    src/parser_stmt.c
     src/printer_schema.c
     src/printer_yang.c
     src/printer_yin.c
diff --git a/src/in.c b/src/in.c
index b893dd2..033b642 100644
--- a/src/in.c
+++ b/src/in.c
@@ -15,16 +15,6 @@
 #define _GNU_SOURCE
 #define _POSIX_C_SOURCE 200809L /* strdup, strndup */
 
-#ifdef __APPLE__
-#define _DARWIN_C_SOURCE /* F_GETPATH */
-#endif
-
-#if defined (__NetBSD__) || defined (__OpenBSD__)
-/* realpath */
-#define _XOPEN_SOURCE 1
-#define _XOPEN_SOURCE_EXTENDED 1
-#endif
-
 #include "in.h"
 #include "in_internal.h"
 
@@ -261,63 +251,6 @@
     return NULL;
 }
 
-void
-lys_parser_fill_filepath(struct ly_ctx *ctx, struct ly_in *in, const char **filepath)
-{
-    char path[PATH_MAX];
-
-#ifndef __APPLE__
-    char proc_path[32];
-    int len;
-#endif
-
-    LY_CHECK_ARG_RET(NULL, ctx, in, filepath, );
-    if (*filepath) {
-        /* filepath already set */
-        return;
-    }
-
-    switch (in->type) {
-    case LY_IN_FILEPATH:
-        if (realpath(in->method.fpath.filepath, path) != NULL) {
-            lydict_insert(ctx, path, 0, filepath);
-        } else {
-            lydict_insert(ctx, in->method.fpath.filepath, 0, filepath);
-        }
-
-        break;
-    case LY_IN_FD:
-#ifdef __APPLE__
-        if (fcntl(in->method.fd, F_GETPATH, path) != -1) {
-            lydict_insert(ctx, path, 0, filepath);
-        }
-#elif defined _WIN32
-        HANDLE h = _get_osfhandle(in->method.fd);
-        FILE_NAME_INFO info;
-        if (GetFileInformationByHandleEx(h, FileNameInfo, &info, sizeof info)) {
-            char *buf = calloc(info.FileNameLength + 1 /* trailing NULL */, MB_CUR_MAX);
-            len = wcstombs(buf, info.FileName, info.FileNameLength * MB_CUR_MAX);
-            lydict_insert(ctx, buf, len, filepath);
-        }
-#else
-        /* get URI if there is /proc */
-        sprintf(proc_path, "/proc/self/fd/%d", in->method.fd);
-        if ((len = readlink(proc_path, path, PATH_MAX - 1)) > 0) {
-            lydict_insert(ctx, path, len, filepath);
-        }
-#endif
-        break;
-    case LY_IN_MEMORY:
-    case LY_IN_FILE:
-        /* nothing to do */
-        break;
-    default:
-        LOGINT(ctx);
-        break;
-    }
-
-}
-
 LIBYANG_API_DEF size_t
 ly_in_parsed(const struct ly_in *in)
 {
@@ -388,164 +321,3 @@
     in->current += count;
     return LY_SUCCESS;
 }
-
-void
-lyd_ctx_free(struct lyd_ctx *lydctx)
-{
-    ly_set_erase(&lydctx->node_types, NULL);
-    ly_set_erase(&lydctx->meta_types, NULL);
-    ly_set_erase(&lydctx->node_when, NULL);
-    ly_set_erase(&lydctx->ext_val, free);
-}
-
-LY_ERR
-lyd_parser_find_operation(const struct lyd_node *parent, uint32_t int_opts, struct lyd_node **op)
-{
-    const struct lyd_node *iter;
-
-    *op = NULL;
-
-    if (!parent) {
-        /* no parent, nothing to look for */
-        return LY_SUCCESS;
-    }
-
-    /* we need to find the operation node if it already exists */
-    for (iter = parent; iter; iter = lyd_parent(iter)) {
-        if (iter->schema && (iter->schema->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF))) {
-            break;
-        }
-    }
-
-    if (!iter) {
-        /* no operation found */
-        return LY_SUCCESS;
-    }
-
-    if (!(int_opts & (LYD_INTOPT_RPC | LYD_INTOPT_ACTION | LYD_INTOPT_NOTIF | LYD_INTOPT_REPLY))) {
-        LOGERR(LYD_CTX(parent), LY_EINVAL, "Invalid parent %s \"%s\" node when not parsing any operation.",
-                lys_nodetype2str(iter->schema->nodetype), iter->schema->name);
-        return LY_EINVAL;
-    } else if ((iter->schema->nodetype == LYS_RPC) && !(int_opts & (LYD_INTOPT_RPC | LYD_INTOPT_REPLY))) {
-        LOGERR(LYD_CTX(parent), LY_EINVAL, "Invalid parent RPC \"%s\" node when not parsing RPC nor rpc-reply.",
-                iter->schema->name);
-        return LY_EINVAL;
-    } else if ((iter->schema->nodetype == LYS_ACTION) && !(int_opts & (LYD_INTOPT_ACTION | LYD_INTOPT_REPLY))) {
-        LOGERR(LYD_CTX(parent), LY_EINVAL, "Invalid parent action \"%s\" node when not parsing action nor rpc-reply.",
-                iter->schema->name);
-        return LY_EINVAL;
-    } else if ((iter->schema->nodetype == LYS_NOTIF) && !(int_opts & LYD_INTOPT_NOTIF)) {
-        LOGERR(LYD_CTX(parent), LY_EINVAL, "Invalid parent notification \"%s\" node when not parsing a notification.",
-                iter->schema->name);
-        return LY_EINVAL;
-    }
-
-    *op = (struct lyd_node *)iter;
-    return LY_SUCCESS;
-}
-
-LY_ERR
-lyd_parser_check_schema(struct lyd_ctx *lydctx, const struct lysc_node *snode)
-{
-    LY_ERR rc = LY_SUCCESS;
-
-    LOG_LOCSET(snode, NULL, NULL, NULL);
-
-    if (lydctx->int_opts & LYD_INTOPT_ANY) {
-        /* nothing to check, everything is allowed */
-        goto cleanup;
-    }
-
-    if ((lydctx->parse_opts & LYD_PARSE_NO_STATE) && (snode->flags & LYS_CONFIG_R)) {
-        LOGVAL(lydctx->data_ctx->ctx, LY_VCODE_UNEXPNODE, "state", snode->name);
-        rc = LY_EVALID;
-        goto cleanup;
-    }
-
-    if (snode->nodetype == LYS_RPC) {
-        if (lydctx->int_opts & (LYD_INTOPT_RPC | LYD_INTOPT_REPLY)) {
-            if (lydctx->op_node) {
-                goto error_node_dup;
-            }
-        } else {
-            goto error_node_inval;
-        }
-    } else if (snode->nodetype == LYS_ACTION) {
-        if (lydctx->int_opts & (LYD_INTOPT_ACTION | LYD_INTOPT_REPLY)) {
-            if (lydctx->op_node) {
-                goto error_node_dup;
-            }
-        } else {
-            goto error_node_inval;
-        }
-    } else if (snode->nodetype == LYS_NOTIF) {
-        if (lydctx->int_opts & LYD_INTOPT_NOTIF) {
-            if (lydctx->op_node) {
-                goto error_node_dup;
-            }
-        } else {
-            goto error_node_inval;
-        }
-    }
-
-    /* success */
-    goto cleanup;
-
-error_node_dup:
-    LOGVAL(lydctx->data_ctx->ctx, LYVE_DATA, "Unexpected %s element \"%s\", %s \"%s\" already parsed.",
-            lys_nodetype2str(snode->nodetype), snode->name, lys_nodetype2str(lydctx->op_node->schema->nodetype),
-            lydctx->op_node->schema->name);
-    rc = LY_EVALID;
-    goto cleanup;
-
-error_node_inval:
-    LOGVAL(lydctx->data_ctx->ctx, LYVE_DATA, "Unexpected %s element \"%s\".", lys_nodetype2str(snode->nodetype),
-            snode->name);
-    rc = LY_EVALID;
-
-cleanup:
-    LOG_LOCBACK(1, 0, 0, 0);
-    return rc;
-}
-
-LY_ERR
-lyd_parser_create_term(struct lyd_ctx *lydctx, const struct lysc_node *schema, const void *value, size_t value_len,
-        ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, struct lyd_node **node)
-{
-    ly_bool incomplete;
-
-    LY_CHECK_RET(lyd_create_term(schema, value, value_len, dynamic, format, prefix_data, hints, &incomplete, node));
-
-    if (incomplete && !(lydctx->parse_opts & LYD_PARSE_ONLY)) {
-        LY_CHECK_RET(ly_set_add(&lydctx->node_types, *node, 1, NULL));
-    }
-    return LY_SUCCESS;
-}
-
-LY_ERR
-lyd_parser_create_meta(struct lyd_ctx *lydctx, struct lyd_node *parent, struct lyd_meta **meta, const struct lys_module *mod,
-        const char *name, size_t name_len, const void *value, size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format,
-        void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node)
-{
-    ly_bool incomplete;
-    struct lyd_meta *first = NULL;
-
-    if (meta && *meta) {
-        /* remember the first metadata */
-        first = *meta;
-    }
-
-    LY_CHECK_RET(lyd_create_meta(parent, meta, mod, name, name_len, value, value_len, dynamic, format, prefix_data,
-            hints, ctx_node, 0, &incomplete));
-
-    if (incomplete && !(lydctx->parse_opts & LYD_PARSE_ONLY)) {
-        LY_CHECK_RET(ly_set_add(&lydctx->meta_types, *meta, 1, NULL));
-    }
-
-    if (first) {
-        /* always return the first metadata */
-        *meta = first;
-    }
-
-    return LY_SUCCESS;
-}
diff --git a/src/parser_stmt.c b/src/parser_common.c
similarity index 90%
rename from src/parser_stmt.c
rename to src/parser_common.c
index 81ccbfc..5c345bb 100644
--- a/src/parser_stmt.c
+++ b/src/parser_common.c
@@ -1,9 +1,9 @@
 /**
- * @file parser_stmt.c
- * @author Radek Krejčí <rkrejci@cesnet.cz>
- * @brief Parser of the extension substatements.
+ * @file parser_common.c
+ * @author Michal Vasko <mvasko@cesnet.cz>
+ * @brief libyang common parser functions.
  *
- * Copyright (c) 2019 CESNET, z.s.p.o.
+ * Copyright (c) 2015 - 2022 CESNET, z.s.p.o.
  *
  * This source code is licensed under BSD 3-Clause License (the "License").
  * You may not use this file except in compliance with the License.
@@ -12,25 +12,207 @@
  *     https://opensource.org/licenses/BSD-3-Clause
  */
 
+#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup, strndup */
+
+#ifdef __APPLE__
+#define _DARWIN_C_SOURCE /* F_GETPATH */
+#endif
+
+#if defined (__NetBSD__) || defined (__OpenBSD__)
+/* realpath */
+#define _XOPEN_SOURCE 1
+#define _XOPEN_SOURCE_EXTENDED 1
+#endif
+
+#include "parser_internal.h"
+
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
 #include <stdint.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "common.h"
+#include "compat.h"
 #include "dict.h"
+#include "in_internal.h"
 #include "log.h"
-#include "parser_schema.h"
+#include "parser_data.h"
 #include "path.h"
-#include "schema_compile.h"
 #include "set.h"
 #include "tree.h"
-#include "tree_edit.h"
+#include "tree_data.h"
+#include "tree_data_internal.h"
 #include "tree_schema.h"
 #include "tree_schema_internal.h"
 
+void
+lyd_ctx_free(struct lyd_ctx *lydctx)
+{
+    ly_set_erase(&lydctx->node_types, NULL);
+    ly_set_erase(&lydctx->meta_types, NULL);
+    ly_set_erase(&lydctx->node_when, NULL);
+    ly_set_erase(&lydctx->ext_val, free);
+}
+
+LY_ERR
+lyd_parser_find_operation(const struct lyd_node *parent, uint32_t int_opts, struct lyd_node **op)
+{
+    const struct lyd_node *iter;
+
+    *op = NULL;
+
+    if (!parent) {
+        /* no parent, nothing to look for */
+        return LY_SUCCESS;
+    }
+
+    /* we need to find the operation node if it already exists */
+    for (iter = parent; iter; iter = lyd_parent(iter)) {
+        if (iter->schema && (iter->schema->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF))) {
+            break;
+        }
+    }
+
+    if (!iter) {
+        /* no operation found */
+        return LY_SUCCESS;
+    }
+
+    if (!(int_opts & (LYD_INTOPT_RPC | LYD_INTOPT_ACTION | LYD_INTOPT_NOTIF | LYD_INTOPT_REPLY))) {
+        LOGERR(LYD_CTX(parent), LY_EINVAL, "Invalid parent %s \"%s\" node when not parsing any operation.",
+                lys_nodetype2str(iter->schema->nodetype), iter->schema->name);
+        return LY_EINVAL;
+    } else if ((iter->schema->nodetype == LYS_RPC) && !(int_opts & (LYD_INTOPT_RPC | LYD_INTOPT_REPLY))) {
+        LOGERR(LYD_CTX(parent), LY_EINVAL, "Invalid parent RPC \"%s\" node when not parsing RPC nor rpc-reply.",
+                iter->schema->name);
+        return LY_EINVAL;
+    } else if ((iter->schema->nodetype == LYS_ACTION) && !(int_opts & (LYD_INTOPT_ACTION | LYD_INTOPT_REPLY))) {
+        LOGERR(LYD_CTX(parent), LY_EINVAL, "Invalid parent action \"%s\" node when not parsing action nor rpc-reply.",
+                iter->schema->name);
+        return LY_EINVAL;
+    } else if ((iter->schema->nodetype == LYS_NOTIF) && !(int_opts & LYD_INTOPT_NOTIF)) {
+        LOGERR(LYD_CTX(parent), LY_EINVAL, "Invalid parent notification \"%s\" node when not parsing a notification.",
+                iter->schema->name);
+        return LY_EINVAL;
+    }
+
+    *op = (struct lyd_node *)iter;
+    return LY_SUCCESS;
+}
+
+LY_ERR
+lyd_parser_check_schema(struct lyd_ctx *lydctx, const struct lysc_node *snode)
+{
+    LY_ERR rc = LY_SUCCESS;
+
+    LOG_LOCSET(snode, NULL, NULL, NULL);
+
+    if (lydctx->int_opts & LYD_INTOPT_ANY) {
+        /* nothing to check, everything is allowed */
+        goto cleanup;
+    }
+
+    if ((lydctx->parse_opts & LYD_PARSE_NO_STATE) && (snode->flags & LYS_CONFIG_R)) {
+        LOGVAL(lydctx->data_ctx->ctx, LY_VCODE_UNEXPNODE, "state", snode->name);
+        rc = LY_EVALID;
+        goto cleanup;
+    }
+
+    if (snode->nodetype == LYS_RPC) {
+        if (lydctx->int_opts & (LYD_INTOPT_RPC | LYD_INTOPT_REPLY)) {
+            if (lydctx->op_node) {
+                goto error_node_dup;
+            }
+        } else {
+            goto error_node_inval;
+        }
+    } else if (snode->nodetype == LYS_ACTION) {
+        if (lydctx->int_opts & (LYD_INTOPT_ACTION | LYD_INTOPT_REPLY)) {
+            if (lydctx->op_node) {
+                goto error_node_dup;
+            }
+        } else {
+            goto error_node_inval;
+        }
+    } else if (snode->nodetype == LYS_NOTIF) {
+        if (lydctx->int_opts & LYD_INTOPT_NOTIF) {
+            if (lydctx->op_node) {
+                goto error_node_dup;
+            }
+        } else {
+            goto error_node_inval;
+        }
+    }
+
+    /* success */
+    goto cleanup;
+
+error_node_dup:
+    LOGVAL(lydctx->data_ctx->ctx, LYVE_DATA, "Unexpected %s element \"%s\", %s \"%s\" already parsed.",
+            lys_nodetype2str(snode->nodetype), snode->name, lys_nodetype2str(lydctx->op_node->schema->nodetype),
+            lydctx->op_node->schema->name);
+    rc = LY_EVALID;
+    goto cleanup;
+
+error_node_inval:
+    LOGVAL(lydctx->data_ctx->ctx, LYVE_DATA, "Unexpected %s element \"%s\".", lys_nodetype2str(snode->nodetype),
+            snode->name);
+    rc = LY_EVALID;
+
+cleanup:
+    LOG_LOCBACK(1, 0, 0, 0);
+    return rc;
+}
+
+LY_ERR
+lyd_parser_create_term(struct lyd_ctx *lydctx, const struct lysc_node *schema, const void *value, size_t value_len,
+        ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, struct lyd_node **node)
+{
+    ly_bool incomplete;
+
+    LY_CHECK_RET(lyd_create_term(schema, value, value_len, dynamic, format, prefix_data, hints, &incomplete, node));
+
+    if (incomplete && !(lydctx->parse_opts & LYD_PARSE_ONLY)) {
+        LY_CHECK_RET(ly_set_add(&lydctx->node_types, *node, 1, NULL));
+    }
+    return LY_SUCCESS;
+}
+
+LY_ERR
+lyd_parser_create_meta(struct lyd_ctx *lydctx, struct lyd_node *parent, struct lyd_meta **meta, const struct lys_module *mod,
+        const char *name, size_t name_len, const void *value, size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format,
+        void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node)
+{
+    ly_bool incomplete;
+    struct lyd_meta *first = NULL;
+
+    if (meta && *meta) {
+        /* remember the first metadata */
+        first = *meta;
+    }
+
+    LY_CHECK_RET(lyd_create_meta(parent, meta, mod, name, name_len, value, value_len, dynamic, format, prefix_data,
+            hints, ctx_node, 0, &incomplete));
+
+    if (incomplete && !(lydctx->parse_opts & LYD_PARSE_ONLY)) {
+        LY_CHECK_RET(ly_set_add(&lydctx->meta_types, *meta, 1, NULL));
+    }
+
+    if (first) {
+        /* always return the first metadata */
+        *meta = first;
+    }
+
+    return LY_SUCCESS;
+}
+
 static LY_ERR lysp_stmt_container(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
         struct lysp_node **siblings);
 static LY_ERR lysp_stmt_choice(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
@@ -368,7 +550,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_mandatory(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, uint16_t *flags, struct lysp_ext_instance **exts)
+lysp_stmt_mandatory(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, uint16_t *flags,
+        struct lysp_ext_instance **exts)
 {
     size_t arg_len;
 
@@ -677,7 +860,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_type_fracdigits(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, uint8_t *fracdig, struct lysp_ext_instance **exts)
+lysp_stmt_type_fracdigits(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, uint8_t *fracdig,
+        struct lysp_ext_instance **exts)
 {
     char *ptr;
     size_t arg_len;
@@ -777,7 +961,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_type_pattern_modifier(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, const char **pat, struct lysp_ext_instance **exts)
+lysp_stmt_type_pattern_modifier(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, const char **pat,
+        struct lysp_ext_instance **exts)
 {
     size_t arg_len;
     char *buf;
@@ -1237,7 +1422,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_leaflist(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent, struct lysp_node **siblings)
+lysp_stmt_leaflist(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
+        struct lysp_node **siblings)
 {
     struct lysp_node_leaflist *llist;
 
@@ -1388,7 +1574,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_typedef(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent, struct lysp_tpdf **typedefs)
+lysp_stmt_typedef(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
+        struct lysp_tpdf **typedefs)
 {
     struct lysp_tpdf *tpdf;
 
@@ -1532,7 +1719,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_action(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent, struct lysp_node_action **actions)
+lysp_stmt_action(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
+        struct lysp_node_action **actions)
 {
     struct lysp_node_action *act;
 
@@ -1607,7 +1795,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_notif(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent, struct lysp_node_notif **notifs)
+lysp_stmt_notif(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
+        struct lysp_node_notif **notifs)
 {
     struct lysp_node_notif *notif;
 
@@ -1692,7 +1881,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_grouping(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent, struct lysp_node_grp **groupings)
+lysp_stmt_grouping(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
+        struct lysp_node_grp **groupings)
 {
     struct lysp_node_grp *grp;
 
@@ -1778,7 +1968,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_augment(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent, struct lysp_node_augment **augments)
+lysp_stmt_augment(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
+        struct lysp_node_augment **augments)
 {
     struct lysp_node_augment *aug;
 
@@ -1867,7 +2058,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_uses(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent, struct lysp_node **siblings)
+lysp_stmt_uses(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
+        struct lysp_node **siblings)
 {
     struct lysp_node_uses *uses;
 
@@ -1928,7 +2120,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_case(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent, struct lysp_node **siblings)
+lysp_stmt_case(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
+        struct lysp_node **siblings)
 {
     struct lysp_node_case *cas;
 
@@ -2006,7 +2199,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_choice(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent, struct lysp_node **siblings)
+lysp_stmt_choice(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
+        struct lysp_node **siblings)
 {
     struct lysp_node_choice *choice;
 
@@ -2094,7 +2288,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_container(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent, struct lysp_node **siblings)
+lysp_stmt_container(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
+        struct lysp_node **siblings)
 {
     struct lysp_node_container *cont;
 
@@ -2196,7 +2391,8 @@
  * @return LY_ERR values.
  */
 static LY_ERR
-lysp_stmt_list(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent, struct lysp_node **siblings)
+lysp_stmt_list(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct lysp_node *parent,
+        struct lysp_node **siblings)
 {
     struct lysp_node_list *list;
 
@@ -2474,3 +2670,59 @@
     LOG_LOCBACK(0, 0, 1, 0);
     return ret;
 }
+
+void
+lys_parser_fill_filepath(struct ly_ctx *ctx, struct ly_in *in, const char **filepath)
+{
+    char path[PATH_MAX];
+
+#ifndef __APPLE__
+    char proc_path[32];
+    int len;
+#endif
+
+    LY_CHECK_ARG_RET(NULL, ctx, in, filepath, );
+    if (*filepath) {
+        /* filepath already set */
+        return;
+    }
+
+    switch (in->type) {
+    case LY_IN_FILEPATH:
+        if (realpath(in->method.fpath.filepath, path) != NULL) {
+            lydict_insert(ctx, path, 0, filepath);
+        } else {
+            lydict_insert(ctx, in->method.fpath.filepath, 0, filepath);
+        }
+
+        break;
+    case LY_IN_FD:
+#ifdef __APPLE__
+        if (fcntl(in->method.fd, F_GETPATH, path) != -1) {
+            lydict_insert(ctx, path, 0, filepath);
+        }
+#elif defined _WIN32
+        HANDLE h = _get_osfhandle(in->method.fd);
+        FILE_NAME_INFO info;
+        if (GetFileInformationByHandleEx(h, FileNameInfo, &info, sizeof info)) {
+            char *buf = calloc(info.FileNameLength + 1 /* trailing NULL */, MB_CUR_MAX);
+            len = wcstombs(buf, info.FileName, info.FileNameLength * MB_CUR_MAX);
+            lydict_insert(ctx, buf, len, filepath);
+        }
+#else
+        /* get URI if there is /proc */
+        sprintf(proc_path, "/proc/self/fd/%d", in->method.fd);
+        if ((len = readlink(proc_path, path, PATH_MAX - 1)) > 0) {
+            lydict_insert(ctx, path, len, filepath);
+        }
+#endif
+        break;
+    case LY_IN_MEMORY:
+    case LY_IN_FILE:
+        /* nothing to do */
+        break;
+    default:
+        LOGINT(ctx);
+        break;
+    }
+}
diff --git a/src/tree_data.c b/src/tree_data.c
index 8cbf42d..ea3ad9c 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -51,252 +51,6 @@
 #include "xml.h"
 #include "xpath.h"
 
-static LY_ERR lyd_find_sibling_schema(const struct lyd_node *siblings, const struct lysc_node *schema,
-        struct lyd_node **match);
-
-LY_ERR
-lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct lysc_type *type, const void *value,
-        size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
-        const struct lysc_node *ctx_node, ly_bool *incomplete)
-{
-    LY_ERR ret;
-    struct ly_err_item *err = NULL;
-    uint32_t options = (dynamic && *dynamic ? LYPLG_TYPE_STORE_DYNAMIC : 0);
-
-    if (!value) {
-        value = "";
-    }
-    if (incomplete) {
-        *incomplete = 0;
-    }
-
-    ret = type->plugin->store(ctx, type, value, value_len, options, format, prefix_data, hints, ctx_node, val, NULL, &err);
-    if (dynamic) {
-        *dynamic = 0;
-    }
-
-    if (ret == LY_EINCOMPLETE) {
-        if (incomplete) {
-            *incomplete = 1;
-        }
-    } else if (ret) {
-        if (err) {
-            LOGVAL_ERRITEM(ctx, err);
-            ly_err_free(err);
-        } else {
-            LOGVAL(ctx, LYVE_OTHER, "Storing value failed.");
-        }
-        return ret;
-    }
-
-    return LY_SUCCESS;
-}
-
-LY_ERR
-lyd_value_validate_incomplete(const struct ly_ctx *ctx, const struct lysc_type *type, struct lyd_value *val,
-        const struct lyd_node *ctx_node, const struct lyd_node *tree)
-{
-    LY_ERR ret;
-    struct ly_err_item *err = NULL;
-
-    assert(type->plugin->validate);
-
-    ret = type->plugin->validate(ctx, type, ctx_node, tree, val, &err);
-    if (ret) {
-        if (err) {
-            LOGVAL_ERRITEM(ctx, err);
-            ly_err_free(err);
-        } else {
-            LOGVAL(ctx, LYVE_OTHER, "Resolving value \"%s\" failed.", type->plugin->print(ctx, val, LY_VALUE_CANON,
-                    NULL, NULL, NULL));
-        }
-        return ret;
-    }
-
-    return LY_SUCCESS;
-}
-
-LY_ERR
-lys_value_validate(const struct ly_ctx *ctx, const struct lysc_node *node, const char *value, size_t value_len,
-        LY_VALUE_FORMAT format, void *prefix_data)
-{
-    LY_ERR rc = LY_SUCCESS;
-    struct ly_err_item *err = NULL;
-    struct lyd_value storage;
-    struct lysc_type *type;
-
-    LY_CHECK_ARG_RET(ctx, node, value, LY_EINVAL);
-
-    if (!(node->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
-        LOGARG(ctx, node);
-        return LY_EINVAL;
-    }
-
-    type = ((struct lysc_node_leaf *)node)->type;
-    rc = type->plugin->store(ctx ? ctx : node->module->ctx, type, value, value_len, 0, format, prefix_data,
-            LYD_HINT_SCHEMA, node, &storage, NULL, &err);
-    if (rc == LY_EINCOMPLETE) {
-        /* actually success since we do not provide the context tree and call validation with
-         * LY_TYPE_OPTS_INCOMPLETE_DATA */
-        rc = LY_SUCCESS;
-    } else if (rc && err) {
-        if (ctx) {
-            /* log only in case the ctx was provided as input parameter */
-            LOG_LOCSET(NULL, NULL, err->path, NULL);
-            LOGVAL_ERRITEM(ctx, err);
-            LOG_LOCBACK(0, 0, 1, 0);
-        }
-        ly_err_free(err);
-    }
-
-    if (!rc) {
-        type->plugin->free(ctx ? ctx : node->module->ctx, &storage);
-    }
-    return rc;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_value_validate(const struct ly_ctx *ctx, const struct lysc_node *schema, const char *value, size_t value_len,
-        const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical)
-{
-    LY_ERR rc;
-    struct ly_err_item *err = NULL;
-    struct lysc_type *type;
-    struct lyd_value val = {0};
-    ly_bool stored = 0, log = 1;
-
-    LY_CHECK_ARG_RET(ctx, schema, value, LY_EINVAL);
-
-    if (!ctx) {
-        ctx = schema->module->ctx;
-        log = 0;
-    }
-    type = ((struct lysc_node_leaf *)schema)->type;
-
-    /* store */
-    rc = type->plugin->store(ctx, type, value, value_len, 0, LY_VALUE_JSON, NULL,
-            LYD_HINT_DATA, schema, &val, NULL, &err);
-    if (!rc || (rc == LY_EINCOMPLETE)) {
-        stored = 1;
-    }
-
-    if (ctx_node && (rc == LY_EINCOMPLETE)) {
-        /* resolve */
-        rc = type->plugin->validate(ctx, type, ctx_node, ctx_node, &val, &err);
-    }
-
-    if (rc && (rc != LY_EINCOMPLETE) && err) {
-        if (log) {
-            /* log error */
-            if (err->path) {
-                LOG_LOCSET(NULL, NULL, err->path, NULL);
-            } else if (ctx_node) {
-                LOG_LOCSET(NULL, ctx_node, NULL, NULL);
-            } else {
-                LOG_LOCSET(schema, NULL, NULL, NULL);
-            }
-            LOGVAL_ERRITEM(ctx, err);
-            if (err->path) {
-                LOG_LOCBACK(0, 0, 1, 0);
-            } else if (ctx_node) {
-                LOG_LOCBACK(0, 1, 0, 0);
-            } else {
-                LOG_LOCBACK(1, 0, 0, 0);
-            }
-        }
-        ly_err_free(err);
-    }
-
-    if (!rc || (rc == LY_EINCOMPLETE)) {
-        if (realtype) {
-            /* return realtype */
-            if (val.realtype->basetype == LY_TYPE_UNION) {
-                *realtype = val.subvalue->value.realtype;
-            } else {
-                *realtype = val.realtype;
-            }
-        }
-
-        if (canonical) {
-            /* return canonical value */
-            lydict_insert(ctx, val.realtype->plugin->print(ctx, &val, LY_VALUE_CANON, NULL, NULL, NULL), 0, canonical);
-        }
-    }
-
-    if (stored) {
-        /* free value */
-        type->plugin->free(ctx ? ctx : schema->module->ctx, &val);
-    }
-    return rc;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len)
-{
-    LY_ERR ret = LY_SUCCESS;
-    struct ly_ctx *ctx;
-    struct lysc_type *type;
-    struct lyd_value val = {0};
-
-    LY_CHECK_ARG_RET(node ? node->schema->module->ctx : NULL, node, value, LY_EINVAL);
-
-    ctx = node->schema->module->ctx;
-    type = ((struct lysc_node_leaf *)node->schema)->type;
-
-    /* store the value */
-    LOG_LOCSET(node->schema, &node->node, NULL, NULL);
-    ret = lyd_value_store(ctx, &val, type, value, value_len, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, node->schema, NULL);
-    LOG_LOCBACK(1, 1, 0, 0);
-    LY_CHECK_RET(ret);
-
-    /* compare values */
-    ret = type->plugin->compare(&node->value, &val);
-
-    type->plugin->free(ctx, &val);
-    return ret;
-}
-
-LIBYANG_API_DEF ly_bool
-lyd_is_default(const struct lyd_node *node)
-{
-    const struct lysc_node_leaf *leaf;
-    const struct lysc_node_leaflist *llist;
-    const struct lyd_node_term *term;
-    LY_ARRAY_COUNT_TYPE u;
-
-    if (!(node->schema->nodetype & LYD_NODE_TERM)) {
-        return 0;
-    }
-
-    term = (const struct lyd_node_term *)node;
-
-    if (node->schema->nodetype == LYS_LEAF) {
-        leaf = (const struct lysc_node_leaf *)node->schema;
-        if (!leaf->dflt) {
-            return 0;
-        }
-
-        /* compare with the default value */
-        if (!leaf->type->plugin->compare(&term->value, leaf->dflt)) {
-            return 1;
-        }
-    } else {
-        llist = (const struct lysc_node_leaflist *)node->schema;
-        if (!llist->dflts) {
-            return 0;
-        }
-
-        LY_ARRAY_FOR(llist->dflts, u) {
-            /* compare with each possible default value */
-            if (!llist->type->plugin->compare(&term->value, llist->dflts[u])) {
-                return 1;
-            }
-        }
-    }
-
-    return 0;
-}
-
 static LYD_FORMAT
 lyd_parse_get_format(const struct ly_in *in, LYD_FORMAT format)
 {
@@ -645,1763 +399,6 @@
     return lyd_parse_op_(ctx, ext, parent, in, format, data_type, tree, op);
 }
 
-LY_ERR
-lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_len, ly_bool *dynamic,
-        LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, ly_bool *incomplete, struct lyd_node **node)
-{
-    LY_ERR ret;
-    struct lyd_node_term *term;
-
-    assert(schema->nodetype & LYD_NODE_TERM);
-
-    term = calloc(1, sizeof *term);
-    LY_CHECK_ERR_RET(!term, LOGMEM(schema->module->ctx), LY_EMEM);
-
-    term->schema = schema;
-    term->prev = &term->node;
-    term->flags = LYD_NEW;
-
-    LOG_LOCSET(schema, NULL, NULL, NULL);
-    ret = lyd_value_store(schema->module->ctx, &term->value, ((struct lysc_node_leaf *)term->schema)->type, value,
-            value_len, dynamic, format, prefix_data, hints, schema, incomplete);
-    LOG_LOCBACK(1, 0, 0, 0);
-    LY_CHECK_ERR_RET(ret, free(term), ret);
-    lyd_hash(&term->node);
-
-    *node = &term->node;
-    return ret;
-}
-
-LY_ERR
-lyd_create_term2(const struct lysc_node *schema, const struct lyd_value *val, struct lyd_node **node)
-{
-    LY_ERR ret;
-    struct lyd_node_term *term;
-    struct lysc_type *type;
-
-    assert(schema->nodetype & LYD_NODE_TERM);
-    assert(val && val->realtype);
-
-    term = calloc(1, sizeof *term);
-    LY_CHECK_ERR_RET(!term, LOGMEM(schema->module->ctx), LY_EMEM);
-
-    term->schema = schema;
-    term->prev = &term->node;
-    term->flags = LYD_NEW;
-
-    type = ((struct lysc_node_leaf *)schema)->type;
-    ret = type->plugin->duplicate(schema->module->ctx, val, &term->value);
-    if (ret) {
-        LOGERR(schema->module->ctx, ret, "Value duplication failed.");
-        free(term);
-        return ret;
-    }
-    lyd_hash(&term->node);
-
-    *node = &term->node;
-    return ret;
-}
-
-LY_ERR
-lyd_create_inner(const struct lysc_node *schema, struct lyd_node **node)
-{
-    struct lyd_node_inner *in;
-
-    assert(schema->nodetype & LYD_NODE_INNER);
-
-    in = calloc(1, sizeof *in);
-    LY_CHECK_ERR_RET(!in, LOGMEM(schema->module->ctx), LY_EMEM);
-
-    in->schema = schema;
-    in->prev = &in->node;
-    in->flags = LYD_NEW;
-    if ((schema->nodetype == LYS_CONTAINER) && !(schema->flags & LYS_PRESENCE)) {
-        in->flags |= LYD_DEFAULT;
-    }
-
-    /* do not hash list with keys, we need them for the hash */
-    if ((schema->nodetype != LYS_LIST) || (schema->flags & LYS_KEYLESS)) {
-        lyd_hash(&in->node);
-    }
-
-    *node = &in->node;
-    return LY_SUCCESS;
-}
-
-LY_ERR
-lyd_create_list(const struct lysc_node *schema, const struct ly_path_predicate *predicates, struct lyd_node **node)
-{
-    LY_ERR ret = LY_SUCCESS;
-    struct lyd_node *list = NULL, *key;
-    LY_ARRAY_COUNT_TYPE u;
-
-    assert((schema->nodetype == LYS_LIST) && !(schema->flags & LYS_KEYLESS));
-
-    /* create list */
-    LY_CHECK_GOTO(ret = lyd_create_inner(schema, &list), cleanup);
-
-    LOG_LOCSET(NULL, list, NULL, NULL);
-
-    /* create and insert all the keys */
-    LY_ARRAY_FOR(predicates, u) {
-        LY_CHECK_GOTO(ret = lyd_create_term2(predicates[u].key, &predicates[u].value, &key), cleanup);
-        lyd_insert_node(list, NULL, key, 0);
-    }
-
-    /* hash having all the keys */
-    lyd_hash(list);
-
-    /* success */
-    *node = list;
-    list = NULL;
-
-cleanup:
-    LOG_LOCBACK(0, 1, 0, 0);
-    lyd_free_tree(list);
-    return ret;
-}
-
-static LY_ERR
-lyd_create_list2(const struct lysc_node *schema, const char *keys, size_t keys_len, struct lyd_node **node)
-{
-    LY_ERR ret = LY_SUCCESS;
-    struct lyxp_expr *expr = NULL;
-    uint16_t exp_idx = 0;
-    enum ly_path_pred_type pred_type = 0;
-    struct ly_path_predicate *predicates = NULL;
-
-    LOG_LOCSET(schema, NULL, NULL, NULL);
-
-    /* parse keys */
-    LY_CHECK_GOTO(ret = ly_path_parse_predicate(schema->module->ctx, NULL, keys, keys_len, LY_PATH_PREFIX_OPTIONAL,
-            LY_PATH_PRED_KEYS, &expr), cleanup);
-
-    /* compile them */
-    LY_CHECK_GOTO(ret = ly_path_compile_predicate(schema->module->ctx, NULL, NULL, schema, expr, &exp_idx, LY_VALUE_JSON,
-            NULL, &predicates, &pred_type), cleanup);
-
-    /* create the list node */
-    LY_CHECK_GOTO(ret = lyd_create_list(schema, predicates, node), cleanup);
-
-cleanup:
-    LOG_LOCBACK(1, 0, 0, 0);
-    lyxp_expr_free(schema->module->ctx, expr);
-    ly_path_predicates_free(schema->module->ctx, pred_type, predicates);
-    return ret;
-}
-
-LY_ERR
-lyd_create_any(const struct lysc_node *schema, const void *value, LYD_ANYDATA_VALUETYPE value_type, ly_bool use_value,
-        struct lyd_node **node)
-{
-    LY_ERR ret;
-    struct lyd_node_any *any;
-    union lyd_any_value any_val;
-
-    assert(schema->nodetype & LYD_NODE_ANY);
-
-    any = calloc(1, sizeof *any);
-    LY_CHECK_ERR_RET(!any, LOGMEM(schema->module->ctx), LY_EMEM);
-
-    any->schema = schema;
-    any->prev = &any->node;
-    any->flags = LYD_NEW;
-
-    if (use_value) {
-        switch (value_type) {
-        case LYD_ANYDATA_DATATREE:
-            any->value.tree = (void *)value;
-            break;
-        case LYD_ANYDATA_STRING:
-        case LYD_ANYDATA_XML:
-        case LYD_ANYDATA_JSON:
-            LY_CHECK_ERR_RET(lydict_insert_zc(schema->module->ctx, (void *)value, &any->value.str), free(any), LY_EMEM);
-            break;
-        case LYD_ANYDATA_LYB:
-            any->value.mem = (void *)value;
-            break;
-        }
-        any->value_type = value_type;
-    } else {
-        any_val.str = value;
-        ret = lyd_any_copy_value(&any->node, &any_val, value_type);
-        LY_CHECK_ERR_RET(ret, free(any), ret);
-    }
-    lyd_hash(&any->node);
-
-    *node = &any->node;
-    return LY_SUCCESS;
-}
-
-LY_ERR
-lyd_create_opaq(const struct ly_ctx *ctx, const char *name, size_t name_len, const char *prefix, size_t pref_len,
-        const char *module_key, size_t module_key_len, const char *value, size_t value_len, ly_bool *dynamic,
-        LY_VALUE_FORMAT format, void *val_prefix_data, uint32_t hints, struct lyd_node **node)
-{
-    LY_ERR ret = LY_SUCCESS;
-    struct lyd_node_opaq *opaq;
-
-    assert(ctx && name && name_len && format);
-
-    if (!value_len && (!dynamic || !*dynamic)) {
-        value = "";
-    }
-
-    opaq = calloc(1, sizeof *opaq);
-    LY_CHECK_ERR_GOTO(!opaq, LOGMEM(ctx); ret = LY_EMEM, finish);
-
-    opaq->prev = &opaq->node;
-    LY_CHECK_GOTO(ret = lydict_insert(ctx, name, name_len, &opaq->name.name), finish);
-
-    if (pref_len) {
-        LY_CHECK_GOTO(ret = lydict_insert(ctx, prefix, pref_len, &opaq->name.prefix), finish);
-    }
-    if (module_key_len) {
-        LY_CHECK_GOTO(ret = lydict_insert(ctx, module_key, module_key_len, &opaq->name.module_ns), finish);
-    }
-    if (dynamic && *dynamic) {
-        LY_CHECK_GOTO(ret = lydict_insert_zc(ctx, (char *)value, &opaq->value), finish);
-        *dynamic = 0;
-    } else {
-        LY_CHECK_GOTO(ret = lydict_insert(ctx, value, value_len, &opaq->value), finish);
-    }
-
-    opaq->format = format;
-    opaq->val_prefix_data = val_prefix_data;
-    opaq->hints = hints;
-    opaq->ctx = ctx;
-
-finish:
-    if (ret) {
-        lyd_free_tree(&opaq->node);
-        ly_free_prefix_data(format, val_prefix_data);
-    } else {
-        *node = &opaq->node;
-    }
-    return ret;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
-        struct lyd_node **node)
-{
-    LY_ERR r;
-    struct lyd_node *ret = NULL;
-    const struct lysc_node *schema;
-    struct lysc_ext_instance *ext = NULL;
-    const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
-
-    LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
-
-    if (!module) {
-        module = parent->schema->module;
-    }
-
-    schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0,
-            LYS_CONTAINER | LYS_NOTIF | LYS_RPC | LYS_ACTION, output ? LYS_GETNEXT_OUTPUT : 0);
-    if (!schema && parent) {
-        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
-                strlen(name), &schema, &ext);
-        LY_CHECK_RET(r && (r != LY_ENOT), r);
-    }
-    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Inner node (container, notif, RPC, or action) \"%s\" not found.",
-            name), LY_ENOTFOUND);
-
-    LY_CHECK_RET(lyd_create_inner(schema, &ret));
-    if (ext) {
-        ret->flags |= LYD_EXT;
-    }
-    if (parent) {
-        lyd_insert_node(parent, NULL, ret, 0);
-    }
-
-    if (node) {
-        *node = ret;
-    }
-    return LY_SUCCESS;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node)
-{
-    struct lyd_node *ret = NULL;
-    const struct lysc_node *schema;
-    struct ly_ctx *ctx = ext ? ext->module->ctx : NULL;
-
-    LY_CHECK_ARG_RET(ctx, ext, node, name, LY_EINVAL);
-
-    schema = lysc_ext_find_node(ext, NULL, name, 0, LYS_CONTAINER | LYS_NOTIF | LYS_RPC | LYS_ACTION, 0);
-    if (!schema) {
-        if (ext->argument) {
-            LOGERR(ctx, LY_EINVAL, "Inner node (not a list) \"%s\" not found in instance \"%s\" of extension %s.",
-                    name, ext->argument, ext->def->name);
-        } else {
-            LOGERR(ctx, LY_EINVAL, "Inner node (not a list)  \"%s\" not found in instance of extension %s.",
-                    name, ext->def->name);
-        }
-        return LY_ENOTFOUND;
-    }
-    LY_CHECK_RET(lyd_create_inner(schema, &ret));
-
-    *node = ret;
-
-    return LY_SUCCESS;
-}
-
-/**
- * @brief Create a new list node in the data tree.
- *
- * @param[in] parent Parent node for the node being created. NULL in case of creating a top level element.
- * @param[in] module Module of the node being created. If NULL, @p parent module will be used.
- * @param[in] name Schema node name of the new data node. The node must be #LYS_LIST.
- * @param[in] format Format of key values.
- * @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
- * taken into consideration. Otherwise, the output's data node is going to be created.
- * @param[out] node Optional created node.
- * @param[in] ap Ordered key values of the new list instance, all must be set. For ::LY_VALUE_LYB, every value must
- * be followed by the value length.
- * @return LY_ERR value.
- */
-static LY_ERR
-_lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name, LY_VALUE_FORMAT format,
-        ly_bool output, struct lyd_node **node, va_list ap)
-{
-    struct lyd_node *ret = NULL, *key;
-    const struct lysc_node *schema, *key_s;
-    struct lysc_ext_instance *ext = NULL;
-    const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
-    const void *key_val;
-    uint32_t key_len;
-    LY_ERR r, rc = LY_SUCCESS;
-
-    LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
-
-    if (!module) {
-        module = parent->schema->module;
-    }
-
-    schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYS_LIST, output ? LYS_GETNEXT_OUTPUT : 0);
-    if (!schema && parent) {
-        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
-                strlen(name), &schema, &ext);
-        LY_CHECK_RET(r && (r != LY_ENOT), r);
-    }
-    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "List node \"%s\" not found.", name), LY_ENOTFOUND);
-
-    /* create list inner node */
-    LY_CHECK_RET(lyd_create_inner(schema, &ret));
-
-    /* create and insert all the keys */
-    for (key_s = lysc_node_child(schema); key_s && (key_s->flags & LYS_KEY); key_s = key_s->next) {
-        if (format == LY_VALUE_LYB) {
-            key_val = va_arg(ap, const void *);
-            key_len = va_arg(ap, uint32_t);
-        } else {
-            key_val = va_arg(ap, const char *);
-            key_len = key_val ? strlen((char *)key_val) : 0;
-        }
-
-        rc = lyd_create_term(key_s, key_val, key_len, NULL, format, NULL, LYD_HINT_DATA, NULL, &key);
-        LY_CHECK_GOTO(rc, cleanup);
-        lyd_insert_node(ret, NULL, key, 1);
-    }
-
-    if (ext) {
-        ret->flags |= LYD_EXT;
-    }
-    if (parent) {
-        lyd_insert_node(parent, NULL, ret, 0);
-    }
-
-cleanup:
-    if (rc) {
-        lyd_free_tree(ret);
-        ret = NULL;
-    } else if (node) {
-        *node = ret;
-    }
-    return rc;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
-        struct lyd_node **node, ...)
-{
-    LY_ERR rc;
-    va_list ap;
-
-    va_start(ap, node);
-
-    rc = _lyd_new_list(parent, module, name, LY_VALUE_JSON, output, node, ap);
-
-    va_end(ap);
-    return rc;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_list_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
-        struct lyd_node **node, ...)
-{
-    LY_ERR rc;
-    va_list ap;
-
-    va_start(ap, node);
-
-    rc = _lyd_new_list(parent, module, name, LY_VALUE_LYB, output, node, ap);
-
-    va_end(ap);
-    return rc;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_list_canon(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
-        struct lyd_node **node, ...)
-{
-    LY_ERR rc;
-    va_list ap;
-
-    va_start(ap, node);
-
-    rc = _lyd_new_list(parent, module, name, LY_VALUE_CANON, output, node, ap);
-
-    va_end(ap);
-    return rc;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node, ...)
-{
-    struct lyd_node *ret = NULL, *key;
-    const struct lysc_node *schema, *key_s;
-    struct ly_ctx *ctx = ext ? ext->module->ctx : NULL;
-    va_list ap;
-    const char *key_val;
-    LY_ERR rc = LY_SUCCESS;
-
-    LY_CHECK_ARG_RET(ctx, ext, node, name, LY_EINVAL);
-
-    schema = lysc_ext_find_node(ext, NULL, name, 0, LYS_LIST, 0);
-    if (!schema) {
-        if (ext->argument) {
-            LOGERR(ctx, LY_EINVAL, "List node \"%s\" not found in instance \"%s\" of extension %s.",
-                    name, ext->argument, ext->def->name);
-        } else {
-            LOGERR(ctx, LY_EINVAL, "List node \"%s\" not found in instance of extension %s.", name, ext->def->name);
-        }
-        return LY_ENOTFOUND;
-    }
-    /* create list inner node */
-    LY_CHECK_RET(lyd_create_inner(schema, &ret));
-
-    va_start(ap, node);
-
-    /* create and insert all the keys */
-    for (key_s = lysc_node_child(schema); key_s && (key_s->flags & LYS_KEY); key_s = key_s->next) {
-        key_val = va_arg(ap, const char *);
-
-        rc = lyd_create_term(key_s, key_val, key_val ? strlen(key_val) : 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA,
-                NULL, &key);
-        LY_CHECK_GOTO(rc, cleanup);
-        lyd_insert_node(ret, NULL, key, 1);
-    }
-
-cleanup:
-    va_end(ap);
-    if (rc) {
-        lyd_free_tree(ret);
-        ret = NULL;
-    }
-    *node = ret;
-    return rc;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *keys,
-        ly_bool output, struct lyd_node **node)
-{
-    LY_ERR r;
-    struct lyd_node *ret = NULL;
-    const struct lysc_node *schema;
-    struct lysc_ext_instance *ext = NULL;
-    const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
-
-    LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
-
-    if (!module) {
-        module = parent->schema->module;
-    }
-    if (!keys) {
-        keys = "";
-    }
-
-    /* find schema node */
-    schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYS_LIST, output ? LYS_GETNEXT_OUTPUT : 0);
-    if (!schema && parent) {
-        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name, strlen(name),
-                &schema, &ext);
-        LY_CHECK_RET(r && (r != LY_ENOT), r);
-    }
-    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "List node \"%s\" not found.", name), LY_ENOTFOUND);
-
-    if ((schema->flags & LYS_KEYLESS) && !keys[0]) {
-        /* key-less list */
-        LY_CHECK_RET(lyd_create_inner(schema, &ret));
-    } else {
-        /* create the list node */
-        LY_CHECK_RET(lyd_create_list2(schema, keys, strlen(keys), &ret));
-    }
-    if (ext) {
-        ret->flags |= LYD_EXT;
-    }
-    if (parent) {
-        lyd_insert_node(parent, NULL, ret, 0);
-    }
-
-    if (node) {
-        *node = ret;
-    }
-    return LY_SUCCESS;
-}
-
-/**
- * @brief Create a new term node in the data tree.
- *
- * @param[in] parent Parent node for the node being created. NULL in case of creating a top level element.
- * @param[in] module Module of the node being created. If NULL, @p parent module will be used.
- * @param[in] name Schema node name of the new data node. The node can be ::LYS_LEAF or ::LYS_LEAFLIST.
- * @param[in] value Value of the node being created.
- * @param[in] value_len Length of @p value.
- * @param[in] format Format of @p value.
- * @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
- * taken into consideration. Otherwise, the output's data node is going to be created.
- * @param[out] node Optional created node.
- * @return LY_ERR value.
- */
-static LY_ERR
-_lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value,
-        size_t value_len, LY_VALUE_FORMAT format, ly_bool output, struct lyd_node **node)
-{
-    LY_ERR r;
-    struct lyd_node *ret = NULL;
-    const struct lysc_node *schema;
-    struct lysc_ext_instance *ext = NULL;
-    const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
-
-    LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
-
-    if (!module) {
-        module = parent->schema->module;
-    }
-
-    schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYD_NODE_TERM, output ? LYS_GETNEXT_OUTPUT : 0);
-    if (!schema && parent) {
-        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
-                strlen(name), &schema, &ext);
-        LY_CHECK_RET(r && (r != LY_ENOT), r);
-    }
-    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Term node \"%s\" not found.", name), LY_ENOTFOUND);
-
-    LY_CHECK_RET(lyd_create_term(schema, value, value_len, NULL, format, NULL, LYD_HINT_DATA, NULL, &ret));
-    if (ext) {
-        ret->flags |= LYD_EXT;
-    }
-    if (parent) {
-        lyd_insert_node(parent, NULL, ret, 0);
-    }
-
-    if (node) {
-        *node = ret;
-    }
-    return LY_SUCCESS;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str,
-        ly_bool output, struct lyd_node **node)
-{
-    return _lyd_new_term(parent, module, name, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_JSON, output, node);
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value,
-        size_t value_len, ly_bool output, struct lyd_node **node)
-{
-    return _lyd_new_term(parent, module, name, value, value_len, LY_VALUE_LYB, output, node);
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_term_canon(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str,
-        ly_bool output, struct lyd_node **node)
-{
-    return _lyd_new_term(parent, module, name, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_CANON, output, node);
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const char *val_str, struct lyd_node **node)
-{
-    LY_ERR rc;
-    struct lyd_node *ret = NULL;
-    const struct lysc_node *schema;
-    struct ly_ctx *ctx = ext ? ext->module->ctx : NULL;
-
-    LY_CHECK_ARG_RET(ctx, ext, node, name, LY_EINVAL);
-
-    schema = lysc_ext_find_node(ext, NULL, name, 0, LYD_NODE_TERM, 0);
-    if (!schema) {
-        if (ext->argument) {
-            LOGERR(ctx, LY_EINVAL, "Term node \"%s\" not found in instance \"%s\" of extension %s.",
-                    name, ext->argument, ext->def->name);
-        } else {
-            LOGERR(ctx, LY_EINVAL, "Term node \"%s\" not found in instance of extension %s.", name, ext->def->name);
-        }
-        return LY_ENOTFOUND;
-    }
-    rc = lyd_create_term(schema, val_str, val_str ? strlen(val_str) : 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, NULL, &ret);
-    LY_CHECK_RET(rc);
-
-    *node = ret;
-
-    return LY_SUCCESS;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value,
-        ly_bool use_value, LYD_ANYDATA_VALUETYPE value_type, ly_bool output, struct lyd_node **node)
-{
-    LY_ERR r;
-    struct lyd_node *ret = NULL;
-    const struct lysc_node *schema;
-    struct lysc_ext_instance *ext = NULL;
-    const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
-
-    LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
-
-    if (!module) {
-        module = parent->schema->module;
-    }
-
-    schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYD_NODE_ANY, output ? LYS_GETNEXT_OUTPUT : 0);
-    if (!schema && parent) {
-        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
-                strlen(name), &schema, &ext);
-        LY_CHECK_RET(r && (r != LY_ENOT), r);
-    }
-    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Any node \"%s\" not found.", name), LY_ENOTFOUND);
-
-    LY_CHECK_RET(lyd_create_any(schema, value, value_type, use_value, &ret));
-    if (ext) {
-        ret->flags |= LYD_EXT;
-    }
-    if (parent) {
-        lyd_insert_node(parent, NULL, ret, 0);
-    }
-
-    if (node) {
-        *node = ret;
-    }
-    return LY_SUCCESS;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value, ly_bool use_value,
-        LYD_ANYDATA_VALUETYPE value_type, struct lyd_node **node)
-{
-    struct lyd_node *ret = NULL;
-    const struct lysc_node *schema;
-    struct ly_ctx *ctx = ext ? ext->module->ctx : NULL;
-
-    LY_CHECK_ARG_RET(ctx, ext, node, name, LY_EINVAL);
-
-    schema = lysc_ext_find_node(ext, NULL, name, 0, LYD_NODE_ANY, 0);
-    if (!schema) {
-        if (ext->argument) {
-            LOGERR(ctx, LY_EINVAL, "Any node \"%s\" not found in instance \"%s\" of extension %s.",
-                    name, ext->argument, ext->def->name);
-        } else {
-            LOGERR(ctx, LY_EINVAL, "Any node \"%s\" not found in instance of extension %s.", name, ext->def->name);
-        }
-        return LY_ENOTFOUND;
-    }
-    LY_CHECK_RET(lyd_create_any(schema, value, value_type, use_value, &ret));
-
-    *node = ret;
-
-    return LY_SUCCESS;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module, const char *name,
-        const char *val_str, ly_bool clear_dflt, struct lyd_meta **meta)
-{
-    const char *prefix, *tmp;
-    size_t pref_len, name_len;
-
-    LY_CHECK_ARG_RET(ctx, ctx || parent, name, module || strchr(name, ':'), parent || meta, LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(ctx, parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
-    if (!ctx) {
-        ctx = LYD_CTX(parent);
-    }
-
-    if (parent && !parent->schema) {
-        LOGERR(ctx, LY_EINVAL, "Cannot add metadata \"%s\" to an opaque node \"%s\".", name, LYD_NAME(parent));
-        return LY_EINVAL;
-    }
-    if (meta) {
-        *meta = NULL;
-    }
-
-    /* parse the name */
-    tmp = name;
-    if (ly_parse_nodeid(&tmp, &prefix, &pref_len, &name, &name_len) || tmp[0]) {
-        LOGERR(ctx, LY_EINVAL, "Metadata name \"%s\" is not valid.", name);
-        return LY_EINVAL;
-    }
-
-    /* find the module */
-    if (prefix) {
-        module = ly_ctx_get_module_implemented2(ctx, prefix, pref_len);
-        LY_CHECK_ERR_RET(!module, LOGERR(ctx, LY_EINVAL, "Module \"%.*s\" not found.", (int)pref_len, prefix), LY_ENOTFOUND);
-    }
-
-    /* set value if none */
-    if (!val_str) {
-        val_str = "";
-    }
-
-    return lyd_create_meta(parent, meta, module, name, name_len, val_str, strlen(val_str), NULL, LY_VALUE_JSON,
-            NULL, LYD_HINT_DATA, parent ? parent->schema : NULL, clear_dflt, NULL);
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, ly_bool clear_dflt, const struct lyd_attr *attr,
-        struct lyd_meta **meta)
-{
-    const struct lys_module *mod;
-
-    LY_CHECK_ARG_RET(NULL, ctx, attr, parent || meta, LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(ctx, parent ? LYD_CTX(parent) : NULL, LY_EINVAL);
-
-    if (parent && !parent->schema) {
-        LOGERR(ctx, LY_EINVAL, "Cannot add metadata to an opaque node \"%s\".", ((struct lyd_node_opaq *)parent)->name);
-        return LY_EINVAL;
-    }
-    if (meta) {
-        *meta = NULL;
-    }
-
-    switch (attr->format) {
-    case LY_VALUE_XML:
-        mod = ly_ctx_get_module_implemented_ns(ctx, attr->name.module_ns);
-        if (!mod) {
-            LOGERR(ctx, LY_EINVAL, "Module with namespace \"%s\" not found.", attr->name.module_ns);
-            return LY_ENOTFOUND;
-        }
-        break;
-    case LY_VALUE_JSON:
-        mod = ly_ctx_get_module_implemented(ctx, attr->name.module_name);
-        if (!mod) {
-            LOGERR(ctx, LY_EINVAL, "Module \"%s\" not found.", attr->name.module_name);
-            return LY_ENOTFOUND;
-        }
-        break;
-    default:
-        LOGINT_RET(ctx);
-    }
-
-    return lyd_create_meta(parent, meta, mod, attr->name.name, strlen(attr->name.name), attr->value, strlen(attr->value),
-            NULL, attr->format, attr->val_prefix_data, attr->hints, parent ? parent->schema : NULL, clear_dflt, NULL);
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
-        const char *prefix, const char *module_name, struct lyd_node **node)
-{
-    struct lyd_node *ret = NULL;
-
-    LY_CHECK_ARG_RET(ctx, parent || ctx, parent || node, name, module_name, !prefix || !strcmp(prefix, module_name), LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(ctx, parent ? LYD_CTX(parent) : NULL, LY_EINVAL);
-
-    if (!ctx) {
-        ctx = LYD_CTX(parent);
-    }
-    if (!value) {
-        value = "";
-    }
-
-    LY_CHECK_RET(lyd_create_opaq(ctx, name, strlen(name), prefix, prefix ? strlen(prefix) : 0, module_name,
-            strlen(module_name), value, strlen(value), NULL, LY_VALUE_JSON, NULL, 0, &ret));
-    if (parent) {
-        lyd_insert_node(parent, NULL, ret, 1);
-    }
-
-    if (node) {
-        *node = ret;
-    }
-    return LY_SUCCESS;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
-        const char *prefix, const char *module_ns, struct lyd_node **node)
-{
-    struct lyd_node *ret = NULL;
-
-    LY_CHECK_ARG_RET(ctx, parent || ctx, parent || node, name, module_ns, LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(ctx, parent ? LYD_CTX(parent) : NULL, LY_EINVAL);
-
-    if (!ctx) {
-        ctx = LYD_CTX(parent);
-    }
-    if (!value) {
-        value = "";
-    }
-
-    LY_CHECK_RET(lyd_create_opaq(ctx, name, strlen(name), prefix, prefix ? strlen(prefix) : 0, module_ns,
-            strlen(module_ns), value, strlen(value), NULL, LY_VALUE_XML, NULL, 0, &ret));
-    if (parent) {
-        lyd_insert_node(parent, NULL, ret, 1);
-    }
-
-    if (node) {
-        *node = ret;
-    }
-    return LY_SUCCESS;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
-        struct lyd_attr **attr)
-{
-    struct lyd_attr *ret = NULL;
-    const struct ly_ctx *ctx;
-    const char *prefix, *tmp;
-    size_t pref_len, name_len, mod_len;
-
-    LY_CHECK_ARG_RET(NULL, parent, !parent->schema, name, LY_EINVAL);
-
-    ctx = LYD_CTX(parent);
-
-    /* parse the name */
-    tmp = name;
-    if (ly_parse_nodeid(&tmp, &prefix, &pref_len, &name, &name_len) || tmp[0]) {
-        LOGERR(ctx, LY_EINVAL, "Attribute name \"%s\" is not valid.", name);
-        return LY_EVALID;
-    }
-
-    if ((pref_len == 3) && !strncmp(prefix, "xml", 3)) {
-        /* not a prefix but special name */
-        name = prefix;
-        name_len += 1 + pref_len;
-        prefix = NULL;
-        pref_len = 0;
-    }
-
-    /* get the module */
-    if (module_name) {
-        mod_len = strlen(module_name);
-    } else {
-        module_name = prefix;
-        mod_len = pref_len;
-    }
-
-    /* set value if none */
-    if (!value) {
-        value = "";
-    }
-
-    LY_CHECK_RET(lyd_create_attr(parent, &ret, ctx, name, name_len, prefix, pref_len, module_name, mod_len, value,
-            strlen(value), NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA));
-
-    if (attr) {
-        *attr = ret;
-    }
-    return LY_SUCCESS;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
-        struct lyd_attr **attr)
-{
-    struct lyd_attr *ret = NULL;
-    const struct ly_ctx *ctx;
-    const char *prefix, *tmp;
-    size_t pref_len, name_len;
-
-    LY_CHECK_ARG_RET(NULL, parent, !parent->schema, name, LY_EINVAL);
-
-    ctx = LYD_CTX(parent);
-
-    /* parse the name */
-    tmp = name;
-    if (ly_parse_nodeid(&tmp, &prefix, &pref_len, &name, &name_len) || tmp[0]) {
-        LOGERR(ctx, LY_EINVAL, "Attribute name \"%s\" is not valid.", name);
-        return LY_EVALID;
-    }
-
-    if ((pref_len == 3) && !strncmp(prefix, "xml", 3)) {
-        /* not a prefix but special name */
-        name = prefix;
-        name_len += 1 + pref_len;
-        prefix = NULL;
-        pref_len = 0;
-    }
-
-    /* set value if none */
-    if (!value) {
-        value = "";
-    }
-
-    LY_CHECK_RET(lyd_create_attr(parent, &ret, ctx, name, name_len, prefix, pref_len, module_ns,
-            module_ns ? strlen(module_ns) : 0, value, strlen(value), NULL, LY_VALUE_XML, NULL, LYD_HINT_DATA));
-
-    if (attr) {
-        *attr = ret;
-    }
-    return LY_SUCCESS;
-}
-
-/**
- * @brief Change the value of a term (leaf or leaf-list) node.
- *
- * Node changed this way is always considered explicitly set, meaning its default flag
- * is always cleared.
- *
- * @param[in] term Term node to change.
- * @param[in] value New value to set.
- * @param[in] value_len Length of @p value.
- * @param[in] format Format of @p value.
- * @return LY_SUCCESS if value was changed,
- * @return LY_EEXIST if value was the same and only the default flag was cleared,
- * @return LY_ENOT if the values were equal and no change occured,
- * @return LY_ERR value on other errors.
- */
-static LY_ERR
-_lyd_change_term(struct lyd_node *term, const void *value, size_t value_len, LY_VALUE_FORMAT format)
-{
-    LY_ERR ret = LY_SUCCESS;
-    struct lysc_type *type;
-    struct lyd_node_term *t;
-    struct lyd_node *parent;
-    struct lyd_value val;
-    ly_bool dflt_change, val_change;
-
-    assert(term && term->schema && (term->schema->nodetype & LYD_NODE_TERM));
-
-    t = (struct lyd_node_term *)term;
-    type = ((struct lysc_node_leaf *)term->schema)->type;
-
-    /* parse the new value */
-    LOG_LOCSET(term->schema, term, NULL, NULL);
-    ret = lyd_value_store(LYD_CTX(term), &val, type, value, value_len, NULL, format, NULL, LYD_HINT_DATA, term->schema, NULL);
-    LOG_LOCBACK(term->schema ? 1 : 0, 1, 0, 0);
-    LY_CHECK_GOTO(ret, cleanup);
-
-    /* compare original and new value */
-    if (type->plugin->compare(&t->value, &val)) {
-        /* values differ, switch them */
-        type->plugin->free(LYD_CTX(term), &t->value);
-        t->value = val;
-        val_change = 1;
-    } else {
-        /* same values, free the new stored one */
-        type->plugin->free(LYD_CTX(term), &val);
-        val_change = 0;
-    }
-
-    /* always clear the default flag */
-    if (term->flags & LYD_DEFAULT) {
-        for (parent = term; parent; parent = lyd_parent(parent)) {
-            parent->flags &= ~LYD_DEFAULT;
-        }
-        dflt_change = 1;
-    } else {
-        dflt_change = 0;
-    }
-
-    if (val_change || dflt_change) {
-        /* make the node non-validated */
-        term->flags &= LYD_NEW;
-    }
-
-    if (val_change) {
-        if (term->schema->nodetype == LYS_LEAFLIST) {
-            /* leaf-list needs to be hashed again and re-inserted into parent */
-            lyd_unlink_hash(term);
-            lyd_hash(term);
-            LY_CHECK_GOTO(ret = lyd_insert_hash(term), cleanup);
-        } else if ((term->schema->flags & LYS_KEY) && term->parent) {
-            /* list needs to be updated if its key was changed */
-            assert(term->parent->schema->nodetype == LYS_LIST);
-            lyd_unlink_hash(lyd_parent(term));
-            lyd_hash(lyd_parent(term));
-            LY_CHECK_GOTO(ret = lyd_insert_hash(lyd_parent(term)), cleanup);
-        } /* else leaf that is not a key, its value is not used for its hash so it does not change */
-    }
-
-    /* retrun value */
-    if (!val_change) {
-        if (dflt_change) {
-            /* only default flag change */
-            ret = LY_EEXIST;
-        } else {
-            /* no change */
-            ret = LY_ENOT;
-        }
-    } /* else value changed, LY_SUCCESS */
-
-cleanup:
-    return ret;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_change_term(struct lyd_node *term, const char *val_str)
-{
-    LY_CHECK_ARG_RET(NULL, term, term->schema, term->schema->nodetype & LYD_NODE_TERM, LY_EINVAL);
-
-    return _lyd_change_term(term, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_JSON);
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_change_term_bin(struct lyd_node *term, const void *value, size_t value_len)
-{
-    LY_CHECK_ARG_RET(NULL, term, term->schema, term->schema->nodetype & LYD_NODE_TERM, LY_EINVAL);
-
-    return _lyd_change_term(term, value, value_len, LY_VALUE_LYB);
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_change_term_canon(struct lyd_node *term, const char *val_str)
-{
-    LY_CHECK_ARG_RET(NULL, term, term->schema, term->schema->nodetype & LYD_NODE_TERM, LY_EINVAL);
-
-    return _lyd_change_term(term, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_CANON);
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_change_meta(struct lyd_meta *meta, const char *val_str)
-{
-    LY_ERR ret = LY_SUCCESS;
-    struct lyd_meta *m2 = NULL;
-    struct lyd_value val;
-    ly_bool val_change;
-
-    LY_CHECK_ARG_RET(NULL, meta, LY_EINVAL);
-
-    if (!val_str) {
-        val_str = "";
-    }
-
-    /* parse the new value into a new meta structure */
-    ret = lyd_create_meta(NULL, &m2, meta->annotation->module, meta->name, strlen(meta->name), val_str, strlen(val_str),
-            NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, meta->parent ? meta->parent->schema : NULL, 0, NULL);
-    LY_CHECK_GOTO(ret, cleanup);
-
-    /* compare original and new value */
-    if (lyd_compare_meta(meta, m2)) {
-        /* values differ, switch them */
-        val = meta->value;
-        meta->value = m2->value;
-        m2->value = val;
-        val_change = 1;
-    } else {
-        val_change = 0;
-    }
-
-    /* retrun value */
-    if (!val_change) {
-        /* no change */
-        ret = LY_ENOT;
-    } /* else value changed, LY_SUCCESS */
-
-cleanup:
-    lyd_free_meta_single(m2);
-    return ret;
-}
-
-/**
- * @brief Update node value.
- *
- * @param[in] node Node to update.
- * @param[in] value New value to set.
- * @param[in] value_len Length of @p value.
- * @param[in] value_type Type of @p value for anydata/anyxml node.
- * @param[in] format Format of @p value.
- * @param[out] new_parent Set to @p node if the value was updated, otherwise set to NULL.
- * @param[out] new_node Set to @p node if the value was updated, otherwise set to NULL.
- * @return LY_ERR value.
- */
-static LY_ERR
-lyd_new_path_update(struct lyd_node *node, const void *value, size_t value_len, LYD_ANYDATA_VALUETYPE value_type,
-        LY_VALUE_FORMAT format, struct lyd_node **new_parent, struct lyd_node **new_node)
-{
-    LY_ERR ret = LY_SUCCESS;
-    struct lyd_node *new_any;
-
-    switch (node->schema->nodetype) {
-    case LYS_CONTAINER:
-    case LYS_NOTIF:
-    case LYS_RPC:
-    case LYS_ACTION:
-    case LYS_LIST:
-        /* if it exists, there is nothing to update */
-        *new_parent = NULL;
-        *new_node = NULL;
-        break;
-    case LYS_LEAFLIST:
-        if (!lysc_is_dup_inst_list(node->schema)) {
-            /* if it exists, there is nothing to update */
-            *new_parent = NULL;
-            *new_node = NULL;
-            break;
-        }
-    /* fallthrough */
-    case LYS_LEAF:
-        ret = _lyd_change_term(node, value, value_len, format);
-        if ((ret == LY_SUCCESS) || (ret == LY_EEXIST)) {
-            /* there was an actual change (at least of the default flag) */
-            *new_parent = node;
-            *new_node = node;
-            ret = LY_SUCCESS;
-        } else if (ret == LY_ENOT) {
-            /* no change */
-            *new_parent = NULL;
-            *new_node = NULL;
-            ret = LY_SUCCESS;
-        } /* else error */
-        break;
-    case LYS_ANYDATA:
-    case LYS_ANYXML:
-        /* create a new any node */
-        LY_CHECK_RET(lyd_create_any(node->schema, value, value_type, 0, &new_any));
-
-        /* compare with the existing one */
-        if (lyd_compare_single(node, new_any, 0)) {
-            /* not equal, switch values (so that we can use generic node free) */
-            ((struct lyd_node_any *)new_any)->value = ((struct lyd_node_any *)node)->value;
-            ((struct lyd_node_any *)new_any)->value_type = ((struct lyd_node_any *)node)->value_type;
-            ((struct lyd_node_any *)node)->value.str = value;
-            ((struct lyd_node_any *)node)->value_type = value_type;
-
-            *new_parent = node;
-            *new_node = node;
-        } else {
-            /* they are equal */
-            *new_parent = NULL;
-            *new_node = NULL;
-        }
-        lyd_free_tree(new_any);
-        break;
-    default:
-        LOGINT(LYD_CTX(node));
-        ret = LY_EINT;
-        break;
-    }
-
-    return ret;
-}
-
-static LY_ERR
-lyd_new_path_check_find_lypath(struct ly_path *path, const char *str_path, const char *value, size_t value_len,
-        LY_VALUE_FORMAT format, uint32_t options)
-{
-    LY_ERR r;
-    struct ly_path_predicate *pred;
-    struct lyd_value val;
-    const struct lysc_node *schema = NULL;
-    LY_ARRAY_COUNT_TYPE u, new_count;
-    int create = 0;
-
-    assert(path);
-
-    /* go through all the compiled nodes */
-    LY_ARRAY_FOR(path, u) {
-        schema = path[u].node;
-
-        if (lysc_is_dup_inst_list(schema)) {
-            if (path[u].pred_type == LY_PATH_PREDTYPE_NONE) {
-                /* creating a new key-less list or state leaf-list instance */
-                create = 1;
-                new_count = u;
-            } else if (path[u].pred_type != LY_PATH_PREDTYPE_POSITION) {
-                LOG_LOCSET(schema, NULL, NULL, NULL);
-                LOGVAL(schema->module->ctx, LYVE_XPATH, "Invalid predicate for %s \"%s\" in path \"%s\".",
-                        lys_nodetype2str(schema->nodetype), schema->name, str_path);
-                LOG_LOCBACK(1, 0, 0, 0);
-                return LY_EINVAL;
-            }
-        } else if ((schema->nodetype == LYS_LIST) && (path[u].pred_type != LY_PATH_PREDTYPE_LIST)) {
-            if ((u < LY_ARRAY_COUNT(path) - 1) || !(options & LYD_NEW_PATH_OPAQ)) {
-                LOG_LOCSET(schema, NULL, NULL, NULL);
-                LOGVAL(schema->module->ctx, LYVE_XPATH, "Predicate missing for %s \"%s\" in path \"%s\".",
-                        lys_nodetype2str(schema->nodetype), schema->name, str_path);
-                LOG_LOCBACK(1, 0, 0, 0);
-                return LY_EINVAL;
-            } /* else creating an opaque list */
-        } else if ((schema->nodetype == LYS_LEAFLIST) && (path[u].pred_type != LY_PATH_PREDTYPE_LEAFLIST)) {
-            r = LY_SUCCESS;
-            if (options & LYD_NEW_PATH_OPAQ) {
-                r = lyd_value_validate(NULL, schema, value, value_len, NULL, NULL, NULL);
-            }
-            if (!r) {
-                /* try to store the value */
-                LY_CHECK_RET(lyd_value_store(schema->module->ctx, &val, ((struct lysc_node_leaflist *)schema)->type,
-                        value, value_len, NULL, format, NULL, LYD_HINT_DATA, schema, NULL));
-                ++((struct lysc_type *)val.realtype)->refcount;
-
-                /* store the new predicate so that it is used when searching for this instance */
-                path[u].pred_type = LY_PATH_PREDTYPE_LEAFLIST;
-                LY_ARRAY_NEW_RET(schema->module->ctx, path[u].predicates, pred, LY_EMEM);
-                pred->value = val;
-            } /* else we have opaq flag and the value is not valid, leave no predicate and then create an opaque node */
-        }
-    }
-
-    if (create) {
-        /* hide the nodes that should always be created so they are not found */
-        while (new_count < LY_ARRAY_COUNT(path)) {
-            LY_ARRAY_DECREMENT(path);
-        }
-    }
-
-    return LY_SUCCESS;
-}
-
-/**
- * @brief Create a new node in the data tree based on a path. All node types can be created.
- *
- * If @p path points to a list key, the key value from the predicate is used and @p value is ignored.
- * Also, if a leaf-list is being created and both a predicate is defined in @p path
- * and @p value is set, the predicate is preferred.
- *
- * For key-less lists and state leaf-lists, positional predicates can be used. If no preciate is used for these
- * nodes, they are always created.
- *
- * @param[in] parent Data parent to add to/modify, can be NULL. Note that in case a first top-level sibling is used,
- * it may no longer be first if @p path is absolute and starts with a non-existing top-level node inserted
- * before @p parent. Use ::lyd_first_sibling() to adjust @p parent in these cases.
- * @param[in] ctx libyang context, must be set if @p parent is NULL.
- * @param[in] ext Extension instance where the node being created is defined. This argument takes effect only for absolute
- * path or when the relative paths touches document root (top-level). In such cases the present extension instance replaces
- * searching for the appropriate module.
- * @param[in] path [Path](@ref howtoXPath) to create.
- * @param[in] value Value of the new leaf/leaf-list (const char *) in ::LY_VALUE_JSON format. If creating an
- * anyxml/anydata node, the expected type depends on @p value_type. For other node types, it should be NULL.
- * @param[in] value_len Length of @p value in bytes. May be 0 if @p value is a zero-terminated string. Ignored when
- * creating anyxml/anydata nodes.
- * @param[in] value_type Anyxml/anydata node @p value type.
- * @param[in] options Bitmask of options, see @ref pathoptions.
- * @param[out] new_parent Optional first parent node created. If only one node was created, equals to @p new_node.
- * @param[out] new_node Optional last node created.
- * @return LY_ERR value.
- */
-static LY_ERR
-lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const struct lysc_ext_instance *ext, const char *path,
-        const void *value, size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options,
-        struct lyd_node **new_parent, struct lyd_node **new_node)
-{
-    LY_ERR ret = LY_SUCCESS, r;
-    struct lyxp_expr *exp = NULL;
-    struct ly_path *p = NULL;
-    struct lyd_node *nparent = NULL, *nnode = NULL, *node = NULL, *cur_parent;
-    const struct lysc_node *schema;
-    const struct lyd_value *val = NULL;
-    LY_ARRAY_COUNT_TYPE path_idx = 0, orig_count = 0;
-    LY_VALUE_FORMAT format;
-
-    assert(parent || ctx);
-    assert(path && ((path[0] == '/') || parent));
-    assert(!(options & LYD_NEW_PATH_BIN_VALUE) || !(options & LYD_NEW_PATH_CANON_VALUE));
-
-    if (!ctx) {
-        ctx = LYD_CTX(parent);
-    }
-    if (value && !value_len) {
-        value_len = strlen(value);
-    }
-    if (options & LYD_NEW_PATH_BIN_VALUE) {
-        format = LY_VALUE_LYB;
-    } else if (options & LYD_NEW_PATH_CANON_VALUE) {
-        format = LY_VALUE_CANON;
-    } else {
-        format = LY_VALUE_JSON;
-    }
-
-    /* parse path */
-    LY_CHECK_GOTO(ret = ly_path_parse(ctx, NULL, path, strlen(path), 0, LY_PATH_BEGIN_EITHER, LY_PATH_PREFIX_OPTIONAL,
-            LY_PATH_PRED_SIMPLE, &exp), cleanup);
-
-    /* compile path */
-    LY_CHECK_GOTO(ret = ly_path_compile(ctx, NULL, lyd_node_schema(parent), ext, exp, options & LYD_NEW_PATH_OUTPUT ?
-            LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT, LY_PATH_TARGET_MANY, 0, LY_VALUE_JSON, NULL, &p), cleanup);
-
-    /* check the compiled path before searching existing nodes, it may be shortened */
-    orig_count = LY_ARRAY_COUNT(p);
-    LY_CHECK_GOTO(ret = lyd_new_path_check_find_lypath(p, path, value, value_len, format, options), cleanup);
-
-    /* try to find any existing nodes in the path */
-    if (parent) {
-        ret = ly_path_eval_partial(p, parent, &path_idx, &node);
-        if (ret == LY_SUCCESS) {
-            if (orig_count == LY_ARRAY_COUNT(p)) {
-                /* the node exists, are we supposed to update it or is it just a default? */
-                if (!(options & LYD_NEW_PATH_UPDATE) && !(node->flags & LYD_DEFAULT)) {
-                    LOG_LOCSET(NULL, node, NULL, NULL);
-                    LOGVAL(ctx, LYVE_REFERENCE, "Path \"%s\" already exists", path);
-                    LOG_LOCBACK(0, 1, 0, 0);
-                    ret = LY_EEXIST;
-                    goto cleanup;
-                }
-
-                /* update the existing node */
-                ret = lyd_new_path_update(node, value, value_len, value_type, format, &nparent, &nnode);
-                goto cleanup;
-            } /* else we were not searching for the whole path */
-        } else if (ret == LY_EINCOMPLETE) {
-            /* some nodes were found, adjust the iterator to the next segment */
-            ++path_idx;
-        } else if (ret == LY_ENOTFOUND) {
-            /* we will create the nodes from top-level, default behavior (absolute path), or from the parent (relative path) */
-            if (lysc_data_parent(p[0].node)) {
-                node = parent;
-            }
-        } else {
-            /* error */
-            goto cleanup;
-        }
-    }
-
-    /* restore the full path for creating new nodes */
-    while (orig_count > LY_ARRAY_COUNT(p)) {
-        LY_ARRAY_INCREMENT(p);
-    }
-
-    /* create all the non-existing nodes in a loop */
-    for ( ; path_idx < LY_ARRAY_COUNT(p); ++path_idx) {
-        cur_parent = node;
-        schema = p[path_idx].node;
-
-        switch (schema->nodetype) {
-        case LYS_LIST:
-            if (lysc_is_dup_inst_list(schema)) {
-                /* create key-less list instance */
-                LY_CHECK_GOTO(ret = lyd_create_inner(schema, &node), cleanup);
-            } else if ((options & LYD_NEW_PATH_OPAQ) && (p[path_idx].pred_type == LY_PATH_PREDTYPE_NONE)) {
-                /* creating opaque list without keys */
-                LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0,
-                        schema->module->name, strlen(schema->module->name), NULL, 0, NULL, LY_VALUE_JSON, NULL,
-                        LYD_NODEHINT_LIST, &node), cleanup);
-            } else {
-                /* create standard list instance */
-                assert(p[path_idx].pred_type == LY_PATH_PREDTYPE_LIST);
-                LY_CHECK_GOTO(ret = lyd_create_list(schema, p[path_idx].predicates, &node), cleanup);
-            }
-            break;
-        case LYS_CONTAINER:
-        case LYS_NOTIF:
-        case LYS_RPC:
-        case LYS_ACTION:
-            LY_CHECK_GOTO(ret = lyd_create_inner(schema, &node), cleanup);
-            break;
-        case LYS_LEAFLIST:
-            if ((options & LYD_NEW_PATH_OPAQ) && (p[path_idx].pred_type != LY_PATH_PREDTYPE_LEAFLIST)) {
-                /* we have not checked this only for dup-inst lists, otherwise it must be opaque */
-                r = LY_EVALID;
-                if (lysc_is_dup_inst_list(schema)) {
-                    /* validate value */
-                    r = lyd_value_validate(NULL, schema, value ? value : "", value_len, NULL, NULL, NULL);
-                }
-                if (r && (r != LY_EINCOMPLETE)) {
-                    /* creating opaque leaf-list */
-                    LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), value, value_len,
-                            schema->module->name, strlen(schema->module->name), NULL, 0, NULL, format, NULL,
-                            LYD_NODEHINT_LEAFLIST, &node), cleanup);
-                    break;
-                }
-            }
-
-            /* get value to set */
-            if (p[path_idx].pred_type == LY_PATH_PREDTYPE_LEAFLIST) {
-                val = &p[path_idx].predicates[0].value;
-            }
-
-            /* create a leaf-list instance */
-            if (val) {
-                LY_CHECK_GOTO(ret = lyd_create_term2(schema, &p[path_idx].predicates[0].value, &node), cleanup);
-            } else {
-                LY_CHECK_GOTO(ret = lyd_create_term(schema, value, value_len, NULL, format, NULL, LYD_HINT_DATA,
-                        NULL, &node), cleanup);
-            }
-            break;
-        case LYS_LEAF:
-            if (lysc_is_key(schema) && cur_parent->schema) {
-                /* it must have been already created or some error will occur later */
-                lyd_find_sibling_schema(lyd_child(cur_parent), schema, &node);
-                assert(node);
-                goto next_iter;
-            }
-
-            if (options & LYD_NEW_PATH_OPAQ) {
-                if (cur_parent && !cur_parent->schema) {
-                    /* always create opaque nodes for opaque parents */
-                    r = LY_ENOT;
-                } else {
-                    /* validate value */
-                    r = lyd_value_validate(NULL, schema, value ? value : "", value_len, NULL, NULL, NULL);
-                }
-                if (r && (r != LY_EINCOMPLETE)) {
-                    /* creating opaque leaf */
-                    LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), value, value_len,
-                            schema->module->name, strlen(schema->module->name), NULL, 0, NULL, format, NULL, 0, &node),
-                            cleanup);
-                    break;
-                }
-            }
-
-            /* create a leaf instance */
-            LY_CHECK_GOTO(ret = lyd_create_term(schema, value, value_len, NULL, format, NULL, LYD_HINT_DATA, NULL,
-                    &node), cleanup);
-            break;
-        case LYS_ANYDATA:
-        case LYS_ANYXML:
-            LY_CHECK_GOTO(ret = lyd_create_any(schema, value, value_type, 0, &node), cleanup);
-            break;
-        default:
-            LOGINT(ctx);
-            ret = LY_EINT;
-            goto cleanup;
-        }
-
-        if (p[path_idx].ext) {
-            node->flags |= LYD_EXT;
-        }
-        if (cur_parent) {
-            /* connect to the parent */
-            lyd_insert_node(cur_parent, NULL, node, 0);
-        } else if (parent) {
-            /* connect to top-level siblings */
-            lyd_insert_node(NULL, &parent, node, 0);
-        }
-
-next_iter:
-        /* update remembered nodes */
-        if (!nparent) {
-            nparent = node;
-        }
-        nnode = node;
-    }
-
-cleanup:
-    lyxp_expr_free(ctx, exp);
-    if (p) {
-        while (orig_count > LY_ARRAY_COUNT(p)) {
-            LY_ARRAY_INCREMENT(p);
-        }
-    }
-    ly_path_free(ctx, p);
-    if (!ret) {
-        /* set out params only on success */
-        if (new_parent) {
-            *new_parent = nparent;
-        }
-        if (new_node) {
-            *new_node = nnode;
-        }
-    } else {
-        lyd_free_tree(nparent);
-    }
-    return ret;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value, uint32_t options,
-        struct lyd_node **node)
-{
-    LY_CHECK_ARG_RET(ctx, parent || ctx, path, (path[0] == '/') || parent,
-            !(options & LYD_NEW_PATH_BIN_VALUE) || !(options & LYD_NEW_PATH_CANON_VALUE), LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, ctx, LY_EINVAL);
-
-    return lyd_new_path_(parent, ctx, NULL, path, value, 0, LYD_ANYDATA_STRING, options, node, NULL);
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
-        size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent,
-        struct lyd_node **new_node)
-{
-    LY_CHECK_ARG_RET(ctx, parent || ctx, path, (path[0] == '/') || parent,
-            !(options & LYD_NEW_PATH_BIN_VALUE) || !(options & LYD_NEW_PATH_CANON_VALUE), LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, ctx, LY_EINVAL);
-
-    return lyd_new_path_(parent, ctx, NULL, path, value, value_len, value_type, options, new_parent, new_node);
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path, const void *value,
-        uint32_t options, struct lyd_node **node)
-{
-    const struct ly_ctx *ctx = ext ? ext->module->ctx : NULL;
-
-    LY_CHECK_ARG_RET(ctx, ext, path, (path[0] == '/') || parent,
-            !(options & LYD_NEW_PATH_BIN_VALUE) || !(options & LYD_NEW_PATH_CANON_VALUE), LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, ctx, LY_EINVAL);
-
-    return lyd_new_path_(parent, ctx, ext, path, value, 0, LYD_ANYDATA_STRING, options, node, NULL);
-}
-
-LY_ERR
-lyd_new_implicit_r(struct lyd_node *parent, struct lyd_node **first, const struct lysc_node *sparent,
-        const struct lys_module *mod, struct ly_set *node_when, struct ly_set *node_types, uint32_t impl_opts,
-        struct lyd_node **diff)
-{
-    LY_ERR ret;
-    const struct lysc_node *iter = NULL;
-    struct lyd_node *node = NULL;
-    struct lyd_value **dflts;
-    LY_ARRAY_COUNT_TYPE u;
-    uint32_t getnext_opts;
-
-    assert(first && (parent || sparent || mod));
-
-    if (!sparent && parent) {
-        sparent = parent->schema;
-    }
-
-    getnext_opts = LYS_GETNEXT_WITHCHOICE;
-    if (impl_opts & LYD_IMPLICIT_OUTPUT) {
-        getnext_opts |= LYS_GETNEXT_OUTPUT;
-    }
-
-    while ((iter = lys_getnext(iter, sparent, mod ? mod->compiled : NULL, getnext_opts))) {
-        if ((impl_opts & LYD_IMPLICIT_NO_STATE) && (iter->flags & LYS_CONFIG_R)) {
-            continue;
-        } else if ((impl_opts & LYD_IMPLICIT_NO_CONFIG) && (iter->flags & LYS_CONFIG_W)) {
-            continue;
-        }
-
-        switch (iter->nodetype) {
-        case LYS_CHOICE:
-            node = lys_getnext_data(NULL, *first, NULL, iter, NULL);
-            if (!node && ((struct lysc_node_choice *)iter)->dflt) {
-                /* create default case data */
-                LY_CHECK_RET(lyd_new_implicit_r(parent, first, &((struct lysc_node_choice *)iter)->dflt->node,
-                        NULL, node_when, node_types, impl_opts, diff));
-            } else if (node) {
-                /* create any default data in the existing case */
-                assert(node->schema->parent->nodetype == LYS_CASE);
-                LY_CHECK_RET(lyd_new_implicit_r(parent, first, node->schema->parent, NULL, node_when, node_types,
-                        impl_opts, diff));
-            }
-            break;
-        case LYS_CONTAINER:
-            if (!(iter->flags & LYS_PRESENCE) && lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
-                /* create default NP container */
-                LY_CHECK_RET(lyd_create_inner(iter, &node));
-                node->flags = LYD_DEFAULT | (lysc_has_when(iter) ? LYD_WHEN_TRUE : 0);
-                lyd_insert_node(parent, first, node, 0);
-
-                if (lysc_has_when(iter) && node_when) {
-                    /* remember to resolve when */
-                    LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
-                }
-                if (diff) {
-                    /* add into diff */
-                    LY_CHECK_RET(lyd_val_diff_add(node, LYD_DIFF_OP_CREATE, diff));
-                }
-
-                /* create any default children */
-                LY_CHECK_RET(lyd_new_implicit_r(node, lyd_node_child_p(node), NULL, NULL, node_when, node_types,
-                        impl_opts, diff));
-            }
-            break;
-        case LYS_LEAF:
-            if (!(impl_opts & LYD_IMPLICIT_NO_DEFAULTS) && ((struct lysc_node_leaf *)iter)->dflt &&
-                    lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
-                /* create default leaf */
-                ret = lyd_create_term2(iter, ((struct lysc_node_leaf *)iter)->dflt, &node);
-                if (ret == LY_EINCOMPLETE) {
-                    if (node_types) {
-                        /* remember to resolve type */
-                        LY_CHECK_RET(ly_set_add(node_types, node, 1, NULL));
-                    }
-                } else if (ret) {
-                    return ret;
-                }
-                node->flags = LYD_DEFAULT | (lysc_has_when(iter) ? LYD_WHEN_TRUE : 0);
-                lyd_insert_node(parent, first, node, 0);
-
-                if (lysc_has_when(iter) && node_when) {
-                    /* remember to resolve when */
-                    LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
-                }
-                if (diff) {
-                    /* add into diff */
-                    LY_CHECK_RET(lyd_val_diff_add(node, LYD_DIFF_OP_CREATE, diff));
-                }
-            }
-            break;
-        case LYS_LEAFLIST:
-            if (!(impl_opts & LYD_IMPLICIT_NO_DEFAULTS) && ((struct lysc_node_leaflist *)iter)->dflts &&
-                    lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
-                /* create all default leaf-lists */
-                dflts = ((struct lysc_node_leaflist *)iter)->dflts;
-                LY_ARRAY_FOR(dflts, u) {
-                    ret = lyd_create_term2(iter, dflts[u], &node);
-                    if (ret == LY_EINCOMPLETE) {
-                        if (node_types) {
-                            /* remember to resolve type */
-                            LY_CHECK_RET(ly_set_add(node_types, node, 1, NULL));
-                        }
-                    } else if (ret) {
-                        return ret;
-                    }
-                    node->flags = LYD_DEFAULT | (lysc_has_when(iter) ? LYD_WHEN_TRUE : 0);
-                    lyd_insert_node(parent, first, node, 0);
-
-                    if (lysc_has_when(iter) && node_when) {
-                        /* remember to resolve when */
-                        LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
-                    }
-                    if (diff) {
-                        /* add into diff */
-                        LY_CHECK_RET(lyd_val_diff_add(node, LYD_DIFF_OP_CREATE, diff));
-                    }
-                }
-            }
-            break;
-        default:
-            /* without defaults */
-            break;
-        }
-    }
-
-    return LY_SUCCESS;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff)
-{
-    LY_ERR ret = LY_SUCCESS;
-    struct lyd_node *node;
-    struct ly_set node_when = {0};
-
-    LY_CHECK_ARG_RET(NULL, tree, LY_EINVAL);
-    if (diff) {
-        *diff = NULL;
-    }
-
-    LYD_TREE_DFS_BEGIN(tree, node) {
-        /* skip added default nodes */
-        if (((node->flags & (LYD_DEFAULT | LYD_NEW)) != (LYD_DEFAULT | LYD_NEW)) &&
-                (node->schema->nodetype & LYD_NODE_INNER)) {
-            LY_CHECK_GOTO(ret = lyd_new_implicit_r(node, lyd_node_child_p(node), NULL, NULL, &node_when, NULL,
-                    implicit_options, diff), cleanup);
-        }
-
-        LYD_TREE_DFS_END(tree, node);
-    }
-
-    /* resolve when and remove any invalid defaults */
-    LY_CHECK_GOTO(ret = lyd_validate_unres(&tree, NULL, &node_when, LYXP_IGNORE_WHEN, NULL, NULL, NULL, 0, diff), cleanup);
-
-cleanup:
-    ly_set_erase(&node_when, NULL);
-    if (ret && diff) {
-        lyd_free_all(*diff);
-        *diff = NULL;
-    }
-    return ret;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options, struct lyd_node **diff)
-{
-    const struct lys_module *mod;
-    struct lyd_node *d = NULL;
-    uint32_t i = 0;
-    LY_ERR ret = LY_SUCCESS;
-
-    LY_CHECK_ARG_RET(ctx, tree, *tree || ctx, LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(*tree ? LYD_CTX(*tree) : NULL, ctx, LY_EINVAL);
-    if (diff) {
-        *diff = NULL;
-    }
-    if (!ctx) {
-        ctx = LYD_CTX(*tree);
-    }
-
-    /* add nodes for each module one-by-one */
-    while ((mod = ly_ctx_get_module_iter(ctx, &i))) {
-        if (!mod->implemented) {
-            continue;
-        }
-
-        LY_CHECK_GOTO(ret = lyd_new_implicit_module(tree, mod, implicit_options, diff ? &d : NULL), cleanup);
-        if (d) {
-            /* merge into one diff */
-            lyd_insert_sibling(*diff, d, diff);
-
-            d = NULL;
-        }
-    }
-
-cleanup:
-    if (ret && diff) {
-        lyd_free_all(*diff);
-        *diff = NULL;
-    }
-    return ret;
-}
-
-LIBYANG_API_DEF LY_ERR
-lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module, uint32_t implicit_options,
-        struct lyd_node **diff)
-{
-    LY_ERR ret = LY_SUCCESS;
-    struct lyd_node *root, *d = NULL;
-    struct ly_set node_when = {0};
-
-    LY_CHECK_ARG_RET(NULL, tree, module, LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(*tree ? LYD_CTX(*tree) : NULL, module ? module->ctx : NULL, LY_EINVAL);
-    if (diff) {
-        *diff = NULL;
-    }
-
-    /* add all top-level defaults for this module */
-    LY_CHECK_GOTO(ret = lyd_new_implicit_r(NULL, tree, NULL, module, &node_when, NULL, implicit_options, diff), cleanup);
-
-    /* resolve when and remove any invalid defaults */
-    LY_CHECK_GOTO(ret = lyd_validate_unres(tree, module, &node_when, LYXP_IGNORE_WHEN, NULL, NULL, NULL, 0, diff),
-            cleanup);
-
-    /* process nested nodes */
-    LY_LIST_FOR(*tree, root) {
-        /* skip added default nodes */
-        if ((root->flags & (LYD_DEFAULT | LYD_NEW)) != (LYD_DEFAULT | LYD_NEW)) {
-            LY_CHECK_GOTO(ret = lyd_new_implicit_tree(root, implicit_options, diff ? &d : NULL), cleanup);
-
-            if (d) {
-                /* merge into one diff */
-                lyd_insert_sibling(*diff, d, diff);
-
-                d = NULL;
-            }
-        }
-    }
-
-cleanup:
-    ly_set_erase(&node_when, NULL);
-    if (ret && diff) {
-        lyd_free_all(*diff);
-        *diff = NULL;
-    }
-    return ret;
-}
-
 struct lyd_node *
 lyd_insert_get_next_anchor(const struct lyd_node *first_sibling, const struct lyd_node *new_node)
 {
@@ -4443,103 +2440,6 @@
     return LY_SUCCESS;
 }
 
-/**
- * @brief Comparison callback to match schema node with a schema of a data node.
- *
- * @param[in] val1_p Pointer to the schema node
- * @param[in] val2_p Pointer to the data node
- * Implementation of ::lyht_value_equal_cb.
- */
-static ly_bool
-lyd_hash_table_schema_val_equal(void *val1_p, void *val2_p, ly_bool UNUSED(mod), void *UNUSED(cb_data))
-{
-    struct lysc_node *val1;
-    struct lyd_node *val2;
-
-    val1 = *((struct lysc_node **)val1_p);
-    val2 = *((struct lyd_node **)val2_p);
-
-    if (val1 == val2->schema) {
-        /* schema match is enough */
-        return 1;
-    } else {
-        return 0;
-    }
-}
-
-/**
- * @brief Search in the given siblings (NOT recursively) for the first schema node data instance.
- * Uses hashes - should be used whenever possible for best performance.
- *
- * @param[in] siblings Siblings to search in including preceding and succeeding nodes.
- * @param[in] schema Target data node schema to find.
- * @param[out] match Can be NULL, otherwise the found data node.
- * @return LY_SUCCESS on success, @p match set.
- * @return LY_ENOTFOUND if not found, @p match set to NULL.
- * @return LY_ERR value if another error occurred.
- */
-static LY_ERR
-lyd_find_sibling_schema(const struct lyd_node *siblings, const struct lysc_node *schema, struct lyd_node **match)
-{
-    struct lyd_node **match_p;
-    struct lyd_node_inner *parent;
-    uint32_t hash;
-    lyht_value_equal_cb ht_cb;
-
-    assert(siblings && schema);
-
-    parent = siblings->parent;
-    if (parent && parent->schema && parent->children_ht) {
-        /* calculate our hash */
-        hash = dict_hash_multi(0, schema->module->name, strlen(schema->module->name));
-        hash = dict_hash_multi(hash, schema->name, strlen(schema->name));
-        hash = dict_hash_multi(hash, NULL, 0);
-
-        /* use special hash table function */
-        ht_cb = lyht_set_cb(parent->children_ht, lyd_hash_table_schema_val_equal);
-
-        /* find by hash */
-        if (!lyht_find(parent->children_ht, &schema, hash, (void **)&match_p)) {
-            siblings = *match_p;
-        } else {
-            /* not found */
-            siblings = NULL;
-        }
-
-        /* set the original hash table compare function back */
-        lyht_set_cb(parent->children_ht, ht_cb);
-    } else {
-        /* find first sibling */
-        if (siblings->parent) {
-            siblings = siblings->parent->child;
-        } else {
-            while (siblings->prev->next) {
-                siblings = siblings->prev;
-            }
-        }
-
-        /* search manually without hashes */
-        for ( ; siblings; siblings = siblings->next) {
-            if (siblings->schema == schema) {
-                /* schema match is enough */
-                break;
-            }
-        }
-    }
-
-    if (!siblings) {
-        if (match) {
-            *match = NULL;
-        }
-        return LY_ENOTFOUND;
-    }
-
-    if (match) {
-        *match = (struct lyd_node *)siblings;
-    }
-    return LY_SUCCESS;
-}
-
 LIBYANG_API_DEF LY_ERR
 lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema, const char *key_or_value,
         size_t val_len, struct lyd_node **match)
@@ -4846,44 +2746,3 @@
     }
     return LY_SUCCESS;
 }
-
-LIBYANG_API_DEF uint32_t
-lyd_list_pos(const struct lyd_node *instance)
-{
-    const struct lyd_node *iter = NULL;
-    uint32_t pos = 0;
-
-    if (!instance || !(instance->schema->nodetype & (LYS_LIST | LYS_LEAFLIST))) {
-        return 0;
-    }
-
-    /* data instances are ordered, so we can stop when we found instance of other schema node */
-    for (iter = instance; iter->schema == instance->schema; iter = iter->prev) {
-        if (pos && (iter->next == NULL)) {
-            /* overrun to the end of the siblings list */
-            break;
-        }
-        ++pos;
-    }
-
-    return pos;
-}
-
-LIBYANG_API_DEF struct lyd_node *
-lyd_first_sibling(const struct lyd_node *node)
-{
-    struct lyd_node *start;
-
-    if (!node) {
-        return NULL;
-    }
-
-    /* get the first sibling */
-    if (node->parent) {
-        start = node->parent->child;
-    } else {
-        for (start = (struct lyd_node *)node; start->prev->next; start = start->prev) {}
-    }
-
-    return start;
-}
diff --git a/src/tree_data_helpers.c b/src/tree_data_common.c
similarity index 77%
rename from src/tree_data_helpers.c
rename to src/tree_data_common.c
index a364562..762831c 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_common.c
@@ -1,7 +1,8 @@
 /**
- * @file tree_data_helpers.c
+ * @file tree_data_common.c
  * @author Radek Krejci <rkrejci@cesnet.cz>
- * @brief Parsing and validation helper functions for data trees
+ * @author Michal Vasko <mvasko@cesnet.cz>
+ * @brief Parsing and validation common functions for data trees
  *
  * Copyright (c) 2015 - 2022 CESNET, z.s.p.o.
  *
@@ -453,6 +454,290 @@
     return LY_SUCCESS;
 }
 
+LY_ERR
+lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct lysc_type *type, const void *value,
+        size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
+        const struct lysc_node *ctx_node, ly_bool *incomplete)
+{
+    LY_ERR ret;
+    struct ly_err_item *err = NULL;
+    uint32_t options = (dynamic && *dynamic ? LYPLG_TYPE_STORE_DYNAMIC : 0);
+
+    if (!value) {
+        value = "";
+    }
+    if (incomplete) {
+        *incomplete = 0;
+    }
+
+    ret = type->plugin->store(ctx, type, value, value_len, options, format, prefix_data, hints, ctx_node, val, NULL, &err);
+    if (dynamic) {
+        *dynamic = 0;
+    }
+
+    if (ret == LY_EINCOMPLETE) {
+        if (incomplete) {
+            *incomplete = 1;
+        }
+    } else if (ret) {
+        if (err) {
+            LOGVAL_ERRITEM(ctx, err);
+            ly_err_free(err);
+        } else {
+            LOGVAL(ctx, LYVE_OTHER, "Storing value failed.");
+        }
+        return ret;
+    }
+
+    return LY_SUCCESS;
+}
+
+LY_ERR
+lyd_value_validate_incomplete(const struct ly_ctx *ctx, const struct lysc_type *type, struct lyd_value *val,
+        const struct lyd_node *ctx_node, const struct lyd_node *tree)
+{
+    LY_ERR ret;
+    struct ly_err_item *err = NULL;
+
+    assert(type->plugin->validate);
+
+    ret = type->plugin->validate(ctx, type, ctx_node, tree, val, &err);
+    if (ret) {
+        if (err) {
+            LOGVAL_ERRITEM(ctx, err);
+            ly_err_free(err);
+        } else {
+            LOGVAL(ctx, LYVE_OTHER, "Resolving value \"%s\" failed.", type->plugin->print(ctx, val, LY_VALUE_CANON,
+                    NULL, NULL, NULL));
+        }
+        return ret;
+    }
+
+    return LY_SUCCESS;
+}
+
+LY_ERR
+lys_value_validate(const struct ly_ctx *ctx, const struct lysc_node *node, const char *value, size_t value_len,
+        LY_VALUE_FORMAT format, void *prefix_data)
+{
+    LY_ERR rc = LY_SUCCESS;
+    struct ly_err_item *err = NULL;
+    struct lyd_value storage;
+    struct lysc_type *type;
+
+    LY_CHECK_ARG_RET(ctx, node, value, LY_EINVAL);
+
+    if (!(node->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
+        LOGARG(ctx, node);
+        return LY_EINVAL;
+    }
+
+    type = ((struct lysc_node_leaf *)node)->type;
+    rc = type->plugin->store(ctx ? ctx : node->module->ctx, type, value, value_len, 0, format, prefix_data,
+            LYD_HINT_SCHEMA, node, &storage, NULL, &err);
+    if (rc == LY_EINCOMPLETE) {
+        /* actually success since we do not provide the context tree and call validation with
+         * LY_TYPE_OPTS_INCOMPLETE_DATA */
+        rc = LY_SUCCESS;
+    } else if (rc && err) {
+        if (ctx) {
+            /* log only in case the ctx was provided as input parameter */
+            LOG_LOCSET(NULL, NULL, err->path, NULL);
+            LOGVAL_ERRITEM(ctx, err);
+            LOG_LOCBACK(0, 0, 1, 0);
+        }
+        ly_err_free(err);
+    }
+
+    if (!rc) {
+        type->plugin->free(ctx ? ctx : node->module->ctx, &storage);
+    }
+    return rc;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_value_validate(const struct ly_ctx *ctx, const struct lysc_node *schema, const char *value, size_t value_len,
+        const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical)
+{
+    LY_ERR rc;
+    struct ly_err_item *err = NULL;
+    struct lysc_type *type;
+    struct lyd_value val = {0};
+    ly_bool stored = 0, log = 1;
+
+    LY_CHECK_ARG_RET(ctx, schema, value, LY_EINVAL);
+
+    if (!ctx) {
+        ctx = schema->module->ctx;
+        log = 0;
+    }
+    type = ((struct lysc_node_leaf *)schema)->type;
+
+    /* store */
+    rc = type->plugin->store(ctx, type, value, value_len, 0, LY_VALUE_JSON, NULL,
+            LYD_HINT_DATA, schema, &val, NULL, &err);
+    if (!rc || (rc == LY_EINCOMPLETE)) {
+        stored = 1;
+    }
+
+    if (ctx_node && (rc == LY_EINCOMPLETE)) {
+        /* resolve */
+        rc = type->plugin->validate(ctx, type, ctx_node, ctx_node, &val, &err);
+    }
+
+    if (rc && (rc != LY_EINCOMPLETE) && err) {
+        if (log) {
+            /* log error */
+            if (err->path) {
+                LOG_LOCSET(NULL, NULL, err->path, NULL);
+            } else if (ctx_node) {
+                LOG_LOCSET(NULL, ctx_node, NULL, NULL);
+            } else {
+                LOG_LOCSET(schema, NULL, NULL, NULL);
+            }
+            LOGVAL_ERRITEM(ctx, err);
+            if (err->path) {
+                LOG_LOCBACK(0, 0, 1, 0);
+            } else if (ctx_node) {
+                LOG_LOCBACK(0, 1, 0, 0);
+            } else {
+                LOG_LOCBACK(1, 0, 0, 0);
+            }
+        }
+        ly_err_free(err);
+    }
+
+    if (!rc || (rc == LY_EINCOMPLETE)) {
+        if (realtype) {
+            /* return realtype */
+            if (val.realtype->basetype == LY_TYPE_UNION) {
+                *realtype = val.subvalue->value.realtype;
+            } else {
+                *realtype = val.realtype;
+            }
+        }
+
+        if (canonical) {
+            /* return canonical value */
+            lydict_insert(ctx, val.realtype->plugin->print(ctx, &val, LY_VALUE_CANON, NULL, NULL, NULL), 0, canonical);
+        }
+    }
+
+    if (stored) {
+        /* free value */
+        type->plugin->free(ctx ? ctx : schema->module->ctx, &val);
+    }
+    return rc;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len)
+{
+    LY_ERR ret = LY_SUCCESS;
+    struct ly_ctx *ctx;
+    struct lysc_type *type;
+    struct lyd_value val = {0};
+
+    LY_CHECK_ARG_RET(node ? node->schema->module->ctx : NULL, node, value, LY_EINVAL);
+
+    ctx = node->schema->module->ctx;
+    type = ((struct lysc_node_leaf *)node->schema)->type;
+
+    /* store the value */
+    LOG_LOCSET(node->schema, &node->node, NULL, NULL);
+    ret = lyd_value_store(ctx, &val, type, value, value_len, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, node->schema, NULL);
+    LOG_LOCBACK(1, 1, 0, 0);
+    LY_CHECK_RET(ret);
+
+    /* compare values */
+    ret = type->plugin->compare(&node->value, &val);
+
+    type->plugin->free(ctx, &val);
+    return ret;
+}
+
+LIBYANG_API_DEF ly_bool
+lyd_is_default(const struct lyd_node *node)
+{
+    const struct lysc_node_leaf *leaf;
+    const struct lysc_node_leaflist *llist;
+    const struct lyd_node_term *term;
+    LY_ARRAY_COUNT_TYPE u;
+
+    if (!(node->schema->nodetype & LYD_NODE_TERM)) {
+        return 0;
+    }
+
+    term = (const struct lyd_node_term *)node;
+
+    if (node->schema->nodetype == LYS_LEAF) {
+        leaf = (const struct lysc_node_leaf *)node->schema;
+        if (!leaf->dflt) {
+            return 0;
+        }
+
+        /* compare with the default value */
+        if (!leaf->type->plugin->compare(&term->value, leaf->dflt)) {
+            return 1;
+        }
+    } else {
+        llist = (const struct lysc_node_leaflist *)node->schema;
+        if (!llist->dflts) {
+            return 0;
+        }
+
+        LY_ARRAY_FOR(llist->dflts, u) {
+            /* compare with each possible default value */
+            if (!llist->type->plugin->compare(&term->value, llist->dflts[u])) {
+                return 1;
+            }
+        }
+    }
+
+    return 0;
+}
+
+LIBYANG_API_DEF uint32_t
+lyd_list_pos(const struct lyd_node *instance)
+{
+    const struct lyd_node *iter = NULL;
+    uint32_t pos = 0;
+
+    if (!instance || !(instance->schema->nodetype & (LYS_LIST | LYS_LEAFLIST))) {
+        return 0;
+    }
+
+    /* data instances are ordered, so we can stop when we found instance of other schema node */
+    for (iter = instance; iter->schema == instance->schema; iter = iter->prev) {
+        if (pos && (iter->next == NULL)) {
+            /* overrun to the end of the siblings list */
+            break;
+        }
+        ++pos;
+    }
+
+    return pos;
+}
+
+LIBYANG_API_DEF struct lyd_node *
+lyd_first_sibling(const struct lyd_node *node)
+{
+    struct lyd_node *start;
+
+    if (!node) {
+        return NULL;
+    }
+
+    /* get the first sibling */
+    if (node->parent) {
+        start = node->parent->child;
+    } else {
+        for (start = (struct lyd_node *)node; start->prev->next; start = start->prev) {}
+    }
+
+    return start;
+}
+
 /**
  * @brief Check list node parsed into an opaque node for the reason.
  *
@@ -778,6 +1063,93 @@
     return schema;
 }
 
+
+/**
+ * @brief Comparison callback to match schema node with a schema of a data node.
+ *
+ * @param[in] val1_p Pointer to the schema node
+ * @param[in] val2_p Pointer to the data node
+ * Implementation of ::lyht_value_equal_cb.
+ */
+static ly_bool
+lyd_hash_table_schema_val_equal(void *val1_p, void *val2_p, ly_bool UNUSED(mod), void *UNUSED(cb_data))
+{
+    struct lysc_node *val1;
+    struct lyd_node *val2;
+
+    val1 = *((struct lysc_node **)val1_p);
+    val2 = *((struct lyd_node **)val2_p);
+
+    if (val1 == val2->schema) {
+        /* schema match is enough */
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
+LY_ERR
+lyd_find_sibling_schema(const struct lyd_node *siblings, const struct lysc_node *schema, struct lyd_node **match)
+{
+    struct lyd_node **match_p;
+    struct lyd_node_inner *parent;
+    uint32_t hash;
+    lyht_value_equal_cb ht_cb;
+
+    assert(siblings && schema);
+
+    parent = siblings->parent;
+    if (parent && parent->schema && parent->children_ht) {
+        /* calculate our hash */
+        hash = dict_hash_multi(0, schema->module->name, strlen(schema->module->name));
+        hash = dict_hash_multi(hash, schema->name, strlen(schema->name));
+        hash = dict_hash_multi(hash, NULL, 0);
+
+        /* use special hash table function */
+        ht_cb = lyht_set_cb(parent->children_ht, lyd_hash_table_schema_val_equal);
+
+        /* find by hash */
+        if (!lyht_find(parent->children_ht, &schema, hash, (void **)&match_p)) {
+            siblings = *match_p;
+        } else {
+            /* not found */
+            siblings = NULL;
+        }
+
+        /* set the original hash table compare function back */
+        lyht_set_cb(parent->children_ht, ht_cb);
+    } else {
+        /* find first sibling */
+        if (siblings->parent) {
+            siblings = siblings->parent->child;
+        } else {
+            while (siblings->prev->next) {
+                siblings = siblings->prev;
+            }
+        }
+
+        /* search manually without hashes */
+        for ( ; siblings; siblings = siblings->next) {
+            if (siblings->schema == schema) {
+                /* schema match is enough */
+                break;
+            }
+        }
+    }
+
+    if (!siblings) {
+        if (match) {
+            *match = NULL;
+        }
+        return LY_ENOTFOUND;
+    }
+
+    if (match) {
+        *match = (struct lyd_node *)siblings;
+    }
+    return LY_SUCCESS;
+}
+
 void
 lyd_del_move_root(struct lyd_node **root, const struct lyd_node *to_del, const struct lys_module *mod)
 {
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index f95c2d8..0e45bcb 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -146,6 +146,19 @@
 const struct lysc_node *lyd_node_schema(const struct lyd_node *node);
 
 /**
+ * @brief Search in the given siblings (NOT recursively) for the first schema node data instance.
+ * Uses hashes - should be used whenever possible for best performance.
+ *
+ * @param[in] siblings Siblings to search in including preceding and succeeding nodes.
+ * @param[in] schema Target data node schema to find.
+ * @param[out] match Can be NULL, otherwise the found data node.
+ * @return LY_SUCCESS on success, @p match set.
+ * @return LY_ENOTFOUND if not found, @p match set to NULL.
+ * @return LY_ERR value if another error occurred.
+ */
+LY_ERR lyd_find_sibling_schema(const struct lyd_node *siblings, const struct lysc_node *schema, struct lyd_node **match);
+
+/**
  * @brief Check whether a node to be deleted is the root node, move it if it is.
  *
  * @param[in] root Root sibling.
@@ -287,6 +300,20 @@
 LY_ERR lyd_create_list(const struct lysc_node *schema, const struct ly_path_predicate *predicates, struct lyd_node **node);
 
 /**
+ * @brief Create a list with all its keys (cannot be used for key-less list).
+ *
+ * Hash is calculated and new node flag is set.
+ *
+ * @param[in] schema Schema node of the new data node.
+ * @param[in] keys Key list predicates.
+ * @param[in] keys_len Length of @p keys.
+ * @param[out] node Created node.
+ * @return LY_SUCCESS on success.
+ * @return LY_ERR value if an error occurred.
+ */
+LY_ERR lyd_create_list2(const struct lysc_node *schema, const char *keys, size_t keys_len, struct lyd_node **node);
+
+/**
  * @brief Create an anyxml/anydata node.
  *
  * Hash is calculated and flags are properly set based on @p is_valid.
diff --git a/src/tree_data_new.c b/src/tree_data_new.c
new file mode 100644
index 0000000..74f353d
--- /dev/null
+++ b/src/tree_data_new.c
@@ -0,0 +1,1808 @@
+/**
+ * @file tree_data_new.c
+ * @author Radek Krejci <rkrejci@cesnet.cz>
+ * @author Michal Vasko <mvasko@cesnet.cz>
+ * @brief Data tree new functions
+ *
+ * Copyright (c) 2015 - 2022 CESNET, z.s.p.o.
+ *
+ * This source code is licensed under BSD 3-Clause License (the "License").
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     https://opensource.org/licenses/BSD-3-Clause
+ */
+
+#define _GNU_SOURCE
+
+#include <assert.h>
+#include <ctype.h>
+#include <inttypes.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "common.h"
+#include "compat.h"
+#include "context.h"
+#include "dict.h"
+#include "diff.h"
+#include "hash_table.h"
+#include "in.h"
+#include "in_internal.h"
+#include "log.h"
+#include "parser_data.h"
+#include "parser_internal.h"
+#include "path.h"
+#include "plugins.h"
+#include "plugins_exts/metadata.h"
+#include "plugins_internal.h"
+#include "plugins_types.h"
+#include "set.h"
+#include "tree.h"
+#include "tree_data_internal.h"
+#include "tree_edit.h"
+#include "tree_schema.h"
+#include "tree_schema_internal.h"
+#include "validation.h"
+#include "xml.h"
+#include "xpath.h"
+
+LY_ERR
+lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_len, ly_bool *dynamic,
+        LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, ly_bool *incomplete, struct lyd_node **node)
+{
+    LY_ERR ret;
+    struct lyd_node_term *term;
+
+    assert(schema->nodetype & LYD_NODE_TERM);
+
+    term = calloc(1, sizeof *term);
+    LY_CHECK_ERR_RET(!term, LOGMEM(schema->module->ctx), LY_EMEM);
+
+    term->schema = schema;
+    term->prev = &term->node;
+    term->flags = LYD_NEW;
+
+    LOG_LOCSET(schema, NULL, NULL, NULL);
+    ret = lyd_value_store(schema->module->ctx, &term->value, ((struct lysc_node_leaf *)term->schema)->type, value,
+            value_len, dynamic, format, prefix_data, hints, schema, incomplete);
+    LOG_LOCBACK(1, 0, 0, 0);
+    LY_CHECK_ERR_RET(ret, free(term), ret);
+    lyd_hash(&term->node);
+
+    *node = &term->node;
+    return ret;
+}
+
+LY_ERR
+lyd_create_term2(const struct lysc_node *schema, const struct lyd_value *val, struct lyd_node **node)
+{
+    LY_ERR ret;
+    struct lyd_node_term *term;
+    struct lysc_type *type;
+
+    assert(schema->nodetype & LYD_NODE_TERM);
+    assert(val && val->realtype);
+
+    term = calloc(1, sizeof *term);
+    LY_CHECK_ERR_RET(!term, LOGMEM(schema->module->ctx), LY_EMEM);
+
+    term->schema = schema;
+    term->prev = &term->node;
+    term->flags = LYD_NEW;
+
+    type = ((struct lysc_node_leaf *)schema)->type;
+    ret = type->plugin->duplicate(schema->module->ctx, val, &term->value);
+    if (ret) {
+        LOGERR(schema->module->ctx, ret, "Value duplication failed.");
+        free(term);
+        return ret;
+    }
+    lyd_hash(&term->node);
+
+    *node = &term->node;
+    return ret;
+}
+
+LY_ERR
+lyd_create_inner(const struct lysc_node *schema, struct lyd_node **node)
+{
+    struct lyd_node_inner *in;
+
+    assert(schema->nodetype & LYD_NODE_INNER);
+
+    in = calloc(1, sizeof *in);
+    LY_CHECK_ERR_RET(!in, LOGMEM(schema->module->ctx), LY_EMEM);
+
+    in->schema = schema;
+    in->prev = &in->node;
+    in->flags = LYD_NEW;
+    if ((schema->nodetype == LYS_CONTAINER) && !(schema->flags & LYS_PRESENCE)) {
+        in->flags |= LYD_DEFAULT;
+    }
+
+    /* do not hash list with keys, we need them for the hash */
+    if ((schema->nodetype != LYS_LIST) || (schema->flags & LYS_KEYLESS)) {
+        lyd_hash(&in->node);
+    }
+
+    *node = &in->node;
+    return LY_SUCCESS;
+}
+
+LY_ERR
+lyd_create_list(const struct lysc_node *schema, const struct ly_path_predicate *predicates, struct lyd_node **node)
+{
+    LY_ERR ret = LY_SUCCESS;
+    struct lyd_node *list = NULL, *key;
+    LY_ARRAY_COUNT_TYPE u;
+
+    assert((schema->nodetype == LYS_LIST) && !(schema->flags & LYS_KEYLESS));
+
+    /* create list */
+    LY_CHECK_GOTO(ret = lyd_create_inner(schema, &list), cleanup);
+
+    LOG_LOCSET(NULL, list, NULL, NULL);
+
+    /* create and insert all the keys */
+    LY_ARRAY_FOR(predicates, u) {
+        LY_CHECK_GOTO(ret = lyd_create_term2(predicates[u].key, &predicates[u].value, &key), cleanup);
+        lyd_insert_node(list, NULL, key, 0);
+    }
+
+    /* hash having all the keys */
+    lyd_hash(list);
+
+    /* success */
+    *node = list;
+    list = NULL;
+
+cleanup:
+    LOG_LOCBACK(0, 1, 0, 0);
+    lyd_free_tree(list);
+    return ret;
+}
+
+LY_ERR
+lyd_create_list2(const struct lysc_node *schema, const char *keys, size_t keys_len, struct lyd_node **node)
+{
+    LY_ERR ret = LY_SUCCESS;
+    struct lyxp_expr *expr = NULL;
+    uint16_t exp_idx = 0;
+    enum ly_path_pred_type pred_type = 0;
+    struct ly_path_predicate *predicates = NULL;
+
+    LOG_LOCSET(schema, NULL, NULL, NULL);
+
+    /* parse keys */
+    LY_CHECK_GOTO(ret = ly_path_parse_predicate(schema->module->ctx, NULL, keys, keys_len, LY_PATH_PREFIX_OPTIONAL,
+            LY_PATH_PRED_KEYS, &expr), cleanup);
+
+    /* compile them */
+    LY_CHECK_GOTO(ret = ly_path_compile_predicate(schema->module->ctx, NULL, NULL, schema, expr, &exp_idx, LY_VALUE_JSON,
+            NULL, &predicates, &pred_type), cleanup);
+
+    /* create the list node */
+    LY_CHECK_GOTO(ret = lyd_create_list(schema, predicates, node), cleanup);
+
+cleanup:
+    LOG_LOCBACK(1, 0, 0, 0);
+    lyxp_expr_free(schema->module->ctx, expr);
+    ly_path_predicates_free(schema->module->ctx, pred_type, predicates);
+    return ret;
+}
+
+LY_ERR
+lyd_create_any(const struct lysc_node *schema, const void *value, LYD_ANYDATA_VALUETYPE value_type, ly_bool use_value,
+        struct lyd_node **node)
+{
+    LY_ERR ret;
+    struct lyd_node_any *any;
+    union lyd_any_value any_val;
+
+    assert(schema->nodetype & LYD_NODE_ANY);
+
+    any = calloc(1, sizeof *any);
+    LY_CHECK_ERR_RET(!any, LOGMEM(schema->module->ctx), LY_EMEM);
+
+    any->schema = schema;
+    any->prev = &any->node;
+    any->flags = LYD_NEW;
+
+    if (use_value) {
+        switch (value_type) {
+        case LYD_ANYDATA_DATATREE:
+            any->value.tree = (void *)value;
+            break;
+        case LYD_ANYDATA_STRING:
+        case LYD_ANYDATA_XML:
+        case LYD_ANYDATA_JSON:
+            LY_CHECK_ERR_RET(lydict_insert_zc(schema->module->ctx, (void *)value, &any->value.str), free(any), LY_EMEM);
+            break;
+        case LYD_ANYDATA_LYB:
+            any->value.mem = (void *)value;
+            break;
+        }
+        any->value_type = value_type;
+    } else {
+        any_val.str = value;
+        ret = lyd_any_copy_value(&any->node, &any_val, value_type);
+        LY_CHECK_ERR_RET(ret, free(any), ret);
+    }
+    lyd_hash(&any->node);
+
+    *node = &any->node;
+    return LY_SUCCESS;
+}
+
+LY_ERR
+lyd_create_opaq(const struct ly_ctx *ctx, const char *name, size_t name_len, const char *prefix, size_t pref_len,
+        const char *module_key, size_t module_key_len, const char *value, size_t value_len, ly_bool *dynamic,
+        LY_VALUE_FORMAT format, void *val_prefix_data, uint32_t hints, struct lyd_node **node)
+{
+    LY_ERR ret = LY_SUCCESS;
+    struct lyd_node_opaq *opaq;
+
+    assert(ctx && name && name_len && format);
+
+    if (!value_len && (!dynamic || !*dynamic)) {
+        value = "";
+    }
+
+    opaq = calloc(1, sizeof *opaq);
+    LY_CHECK_ERR_GOTO(!opaq, LOGMEM(ctx); ret = LY_EMEM, finish);
+
+    opaq->prev = &opaq->node;
+    LY_CHECK_GOTO(ret = lydict_insert(ctx, name, name_len, &opaq->name.name), finish);
+
+    if (pref_len) {
+        LY_CHECK_GOTO(ret = lydict_insert(ctx, prefix, pref_len, &opaq->name.prefix), finish);
+    }
+    if (module_key_len) {
+        LY_CHECK_GOTO(ret = lydict_insert(ctx, module_key, module_key_len, &opaq->name.module_ns), finish);
+    }
+    if (dynamic && *dynamic) {
+        LY_CHECK_GOTO(ret = lydict_insert_zc(ctx, (char *)value, &opaq->value), finish);
+        *dynamic = 0;
+    } else {
+        LY_CHECK_GOTO(ret = lydict_insert(ctx, value, value_len, &opaq->value), finish);
+    }
+
+    opaq->format = format;
+    opaq->val_prefix_data = val_prefix_data;
+    opaq->hints = hints;
+    opaq->ctx = ctx;
+
+finish:
+    if (ret) {
+        lyd_free_tree(&opaq->node);
+        ly_free_prefix_data(format, val_prefix_data);
+    } else {
+        *node = &opaq->node;
+    }
+    return ret;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
+        struct lyd_node **node)
+{
+    LY_ERR r;
+    struct lyd_node *ret = NULL;
+    const struct lysc_node *schema;
+    struct lysc_ext_instance *ext = NULL;
+    const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
+
+    LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
+
+    if (!module) {
+        module = parent->schema->module;
+    }
+
+    schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0,
+            LYS_CONTAINER | LYS_NOTIF | LYS_RPC | LYS_ACTION, output ? LYS_GETNEXT_OUTPUT : 0);
+    if (!schema && parent) {
+        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
+                strlen(name), &schema, &ext);
+        LY_CHECK_RET(r && (r != LY_ENOT), r);
+    }
+    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Inner node (container, notif, RPC, or action) \"%s\" not found.",
+            name), LY_ENOTFOUND);
+
+    LY_CHECK_RET(lyd_create_inner(schema, &ret));
+    if (ext) {
+        ret->flags |= LYD_EXT;
+    }
+    if (parent) {
+        lyd_insert_node(parent, NULL, ret, 0);
+    }
+
+    if (node) {
+        *node = ret;
+    }
+    return LY_SUCCESS;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node)
+{
+    struct lyd_node *ret = NULL;
+    const struct lysc_node *schema;
+    struct ly_ctx *ctx = ext ? ext->module->ctx : NULL;
+
+    LY_CHECK_ARG_RET(ctx, ext, node, name, LY_EINVAL);
+
+    schema = lysc_ext_find_node(ext, NULL, name, 0, LYS_CONTAINER | LYS_NOTIF | LYS_RPC | LYS_ACTION, 0);
+    if (!schema) {
+        if (ext->argument) {
+            LOGERR(ctx, LY_EINVAL, "Inner node (not a list) \"%s\" not found in instance \"%s\" of extension %s.",
+                    name, ext->argument, ext->def->name);
+        } else {
+            LOGERR(ctx, LY_EINVAL, "Inner node (not a list)  \"%s\" not found in instance of extension %s.",
+                    name, ext->def->name);
+        }
+        return LY_ENOTFOUND;
+    }
+    LY_CHECK_RET(lyd_create_inner(schema, &ret));
+
+    *node = ret;
+
+    return LY_SUCCESS;
+}
+
+/**
+ * @brief Create a new list node in the data tree.
+ *
+ * @param[in] parent Parent node for the node being created. NULL in case of creating a top level element.
+ * @param[in] module Module of the node being created. If NULL, @p parent module will be used.
+ * @param[in] name Schema node name of the new data node. The node must be #LYS_LIST.
+ * @param[in] format Format of key values.
+ * @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
+ * taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[out] node Optional created node.
+ * @param[in] ap Ordered key values of the new list instance, all must be set. For ::LY_VALUE_LYB, every value must
+ * be followed by the value length.
+ * @return LY_ERR value.
+ */
+static LY_ERR
+_lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name, LY_VALUE_FORMAT format,
+        ly_bool output, struct lyd_node **node, va_list ap)
+{
+    struct lyd_node *ret = NULL, *key;
+    const struct lysc_node *schema, *key_s;
+    struct lysc_ext_instance *ext = NULL;
+    const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
+    const void *key_val;
+    uint32_t key_len;
+    LY_ERR r, rc = LY_SUCCESS;
+
+    LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
+
+    if (!module) {
+        module = parent->schema->module;
+    }
+
+    schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYS_LIST, output ? LYS_GETNEXT_OUTPUT : 0);
+    if (!schema && parent) {
+        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
+                strlen(name), &schema, &ext);
+        LY_CHECK_RET(r && (r != LY_ENOT), r);
+    }
+    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "List node \"%s\" not found.", name), LY_ENOTFOUND);
+
+    /* create list inner node */
+    LY_CHECK_RET(lyd_create_inner(schema, &ret));
+
+    /* create and insert all the keys */
+    for (key_s = lysc_node_child(schema); key_s && (key_s->flags & LYS_KEY); key_s = key_s->next) {
+        if (format == LY_VALUE_LYB) {
+            key_val = va_arg(ap, const void *);
+            key_len = va_arg(ap, uint32_t);
+        } else {
+            key_val = va_arg(ap, const char *);
+            key_len = key_val ? strlen((char *)key_val) : 0;
+        }
+
+        rc = lyd_create_term(key_s, key_val, key_len, NULL, format, NULL, LYD_HINT_DATA, NULL, &key);
+        LY_CHECK_GOTO(rc, cleanup);
+        lyd_insert_node(ret, NULL, key, 1);
+    }
+
+    if (ext) {
+        ret->flags |= LYD_EXT;
+    }
+    if (parent) {
+        lyd_insert_node(parent, NULL, ret, 0);
+    }
+
+cleanup:
+    if (rc) {
+        lyd_free_tree(ret);
+        ret = NULL;
+    } else if (node) {
+        *node = ret;
+    }
+    return rc;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
+        struct lyd_node **node, ...)
+{
+    LY_ERR rc;
+    va_list ap;
+
+    va_start(ap, node);
+
+    rc = _lyd_new_list(parent, module, name, LY_VALUE_JSON, output, node, ap);
+
+    va_end(ap);
+    return rc;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_list_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
+        struct lyd_node **node, ...)
+{
+    LY_ERR rc;
+    va_list ap;
+
+    va_start(ap, node);
+
+    rc = _lyd_new_list(parent, module, name, LY_VALUE_LYB, output, node, ap);
+
+    va_end(ap);
+    return rc;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_list_canon(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
+        struct lyd_node **node, ...)
+{
+    LY_ERR rc;
+    va_list ap;
+
+    va_start(ap, node);
+
+    rc = _lyd_new_list(parent, module, name, LY_VALUE_CANON, output, node, ap);
+
+    va_end(ap);
+    return rc;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node, ...)
+{
+    struct lyd_node *ret = NULL, *key;
+    const struct lysc_node *schema, *key_s;
+    struct ly_ctx *ctx = ext ? ext->module->ctx : NULL;
+    va_list ap;
+    const char *key_val;
+    LY_ERR rc = LY_SUCCESS;
+
+    LY_CHECK_ARG_RET(ctx, ext, node, name, LY_EINVAL);
+
+    schema = lysc_ext_find_node(ext, NULL, name, 0, LYS_LIST, 0);
+    if (!schema) {
+        if (ext->argument) {
+            LOGERR(ctx, LY_EINVAL, "List node \"%s\" not found in instance \"%s\" of extension %s.",
+                    name, ext->argument, ext->def->name);
+        } else {
+            LOGERR(ctx, LY_EINVAL, "List node \"%s\" not found in instance of extension %s.", name, ext->def->name);
+        }
+        return LY_ENOTFOUND;
+    }
+    /* create list inner node */
+    LY_CHECK_RET(lyd_create_inner(schema, &ret));
+
+    va_start(ap, node);
+
+    /* create and insert all the keys */
+    for (key_s = lysc_node_child(schema); key_s && (key_s->flags & LYS_KEY); key_s = key_s->next) {
+        key_val = va_arg(ap, const char *);
+
+        rc = lyd_create_term(key_s, key_val, key_val ? strlen(key_val) : 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA,
+                NULL, &key);
+        LY_CHECK_GOTO(rc, cleanup);
+        lyd_insert_node(ret, NULL, key, 1);
+    }
+
+cleanup:
+    va_end(ap);
+    if (rc) {
+        lyd_free_tree(ret);
+        ret = NULL;
+    }
+    *node = ret;
+    return rc;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *keys,
+        ly_bool output, struct lyd_node **node)
+{
+    LY_ERR r;
+    struct lyd_node *ret = NULL;
+    const struct lysc_node *schema;
+    struct lysc_ext_instance *ext = NULL;
+    const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
+
+    LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
+
+    if (!module) {
+        module = parent->schema->module;
+    }
+    if (!keys) {
+        keys = "";
+    }
+
+    /* find schema node */
+    schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYS_LIST, output ? LYS_GETNEXT_OUTPUT : 0);
+    if (!schema && parent) {
+        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name, strlen(name),
+                &schema, &ext);
+        LY_CHECK_RET(r && (r != LY_ENOT), r);
+    }
+    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "List node \"%s\" not found.", name), LY_ENOTFOUND);
+
+    if ((schema->flags & LYS_KEYLESS) && !keys[0]) {
+        /* key-less list */
+        LY_CHECK_RET(lyd_create_inner(schema, &ret));
+    } else {
+        /* create the list node */
+        LY_CHECK_RET(lyd_create_list2(schema, keys, strlen(keys), &ret));
+    }
+    if (ext) {
+        ret->flags |= LYD_EXT;
+    }
+    if (parent) {
+        lyd_insert_node(parent, NULL, ret, 0);
+    }
+
+    if (node) {
+        *node = ret;
+    }
+    return LY_SUCCESS;
+}
+
+/**
+ * @brief Create a new term node in the data tree.
+ *
+ * @param[in] parent Parent node for the node being created. NULL in case of creating a top level element.
+ * @param[in] module Module of the node being created. If NULL, @p parent module will be used.
+ * @param[in] name Schema node name of the new data node. The node can be ::LYS_LEAF or ::LYS_LEAFLIST.
+ * @param[in] value Value of the node being created.
+ * @param[in] value_len Length of @p value.
+ * @param[in] format Format of @p value.
+ * @param[in] output Flag in case the @p parent is RPC/Action. If value is 0, the input's data nodes of the RPC/Action are
+ * taken into consideration. Otherwise, the output's data node is going to be created.
+ * @param[out] node Optional created node.
+ * @return LY_ERR value.
+ */
+static LY_ERR
+_lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value,
+        size_t value_len, LY_VALUE_FORMAT format, ly_bool output, struct lyd_node **node)
+{
+    LY_ERR r;
+    struct lyd_node *ret = NULL;
+    const struct lysc_node *schema;
+    struct lysc_ext_instance *ext = NULL;
+    const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
+
+    LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
+
+    if (!module) {
+        module = parent->schema->module;
+    }
+
+    schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYD_NODE_TERM, output ? LYS_GETNEXT_OUTPUT : 0);
+    if (!schema && parent) {
+        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
+                strlen(name), &schema, &ext);
+        LY_CHECK_RET(r && (r != LY_ENOT), r);
+    }
+    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Term node \"%s\" not found.", name), LY_ENOTFOUND);
+
+    LY_CHECK_RET(lyd_create_term(schema, value, value_len, NULL, format, NULL, LYD_HINT_DATA, NULL, &ret));
+    if (ext) {
+        ret->flags |= LYD_EXT;
+    }
+    if (parent) {
+        lyd_insert_node(parent, NULL, ret, 0);
+    }
+
+    if (node) {
+        *node = ret;
+    }
+    return LY_SUCCESS;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str,
+        ly_bool output, struct lyd_node **node)
+{
+    return _lyd_new_term(parent, module, name, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_JSON, output, node);
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value,
+        size_t value_len, ly_bool output, struct lyd_node **node)
+{
+    return _lyd_new_term(parent, module, name, value, value_len, LY_VALUE_LYB, output, node);
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_term_canon(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str,
+        ly_bool output, struct lyd_node **node)
+{
+    return _lyd_new_term(parent, module, name, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_CANON, output, node);
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const char *val_str, struct lyd_node **node)
+{
+    LY_ERR rc;
+    struct lyd_node *ret = NULL;
+    const struct lysc_node *schema;
+    struct ly_ctx *ctx = ext ? ext->module->ctx : NULL;
+
+    LY_CHECK_ARG_RET(ctx, ext, node, name, LY_EINVAL);
+
+    schema = lysc_ext_find_node(ext, NULL, name, 0, LYD_NODE_TERM, 0);
+    if (!schema) {
+        if (ext->argument) {
+            LOGERR(ctx, LY_EINVAL, "Term node \"%s\" not found in instance \"%s\" of extension %s.",
+                    name, ext->argument, ext->def->name);
+        } else {
+            LOGERR(ctx, LY_EINVAL, "Term node \"%s\" not found in instance of extension %s.", name, ext->def->name);
+        }
+        return LY_ENOTFOUND;
+    }
+    rc = lyd_create_term(schema, val_str, val_str ? strlen(val_str) : 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, NULL, &ret);
+    LY_CHECK_RET(rc);
+
+    *node = ret;
+
+    return LY_SUCCESS;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value,
+        ly_bool use_value, LYD_ANYDATA_VALUETYPE value_type, ly_bool output, struct lyd_node **node)
+{
+    LY_ERR r;
+    struct lyd_node *ret = NULL;
+    const struct lysc_node *schema;
+    struct lysc_ext_instance *ext = NULL;
+    const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
+
+    LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
+
+    if (!module) {
+        module = parent->schema->module;
+    }
+
+    schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYD_NODE_ANY, output ? LYS_GETNEXT_OUTPUT : 0);
+    if (!schema && parent) {
+        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
+                strlen(name), &schema, &ext);
+        LY_CHECK_RET(r && (r != LY_ENOT), r);
+    }
+    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Any node \"%s\" not found.", name), LY_ENOTFOUND);
+
+    LY_CHECK_RET(lyd_create_any(schema, value, value_type, use_value, &ret));
+    if (ext) {
+        ret->flags |= LYD_EXT;
+    }
+    if (parent) {
+        lyd_insert_node(parent, NULL, ret, 0);
+    }
+
+    if (node) {
+        *node = ret;
+    }
+    return LY_SUCCESS;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value, ly_bool use_value,
+        LYD_ANYDATA_VALUETYPE value_type, struct lyd_node **node)
+{
+    struct lyd_node *ret = NULL;
+    const struct lysc_node *schema;
+    struct ly_ctx *ctx = ext ? ext->module->ctx : NULL;
+
+    LY_CHECK_ARG_RET(ctx, ext, node, name, LY_EINVAL);
+
+    schema = lysc_ext_find_node(ext, NULL, name, 0, LYD_NODE_ANY, 0);
+    if (!schema) {
+        if (ext->argument) {
+            LOGERR(ctx, LY_EINVAL, "Any node \"%s\" not found in instance \"%s\" of extension %s.",
+                    name, ext->argument, ext->def->name);
+        } else {
+            LOGERR(ctx, LY_EINVAL, "Any node \"%s\" not found in instance of extension %s.", name, ext->def->name);
+        }
+        return LY_ENOTFOUND;
+    }
+    LY_CHECK_RET(lyd_create_any(schema, value, value_type, use_value, &ret));
+
+    *node = ret;
+
+    return LY_SUCCESS;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module, const char *name,
+        const char *val_str, ly_bool clear_dflt, struct lyd_meta **meta)
+{
+    const char *prefix, *tmp;
+    size_t pref_len, name_len;
+
+    LY_CHECK_ARG_RET(ctx, ctx || parent, name, module || strchr(name, ':'), parent || meta, LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(ctx, parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
+    if (!ctx) {
+        ctx = LYD_CTX(parent);
+    }
+
+    if (parent && !parent->schema) {
+        LOGERR(ctx, LY_EINVAL, "Cannot add metadata \"%s\" to an opaque node \"%s\".", name, LYD_NAME(parent));
+        return LY_EINVAL;
+    }
+    if (meta) {
+        *meta = NULL;
+    }
+
+    /* parse the name */
+    tmp = name;
+    if (ly_parse_nodeid(&tmp, &prefix, &pref_len, &name, &name_len) || tmp[0]) {
+        LOGERR(ctx, LY_EINVAL, "Metadata name \"%s\" is not valid.", name);
+        return LY_EINVAL;
+    }
+
+    /* find the module */
+    if (prefix) {
+        module = ly_ctx_get_module_implemented2(ctx, prefix, pref_len);
+        LY_CHECK_ERR_RET(!module, LOGERR(ctx, LY_EINVAL, "Module \"%.*s\" not found.", (int)pref_len, prefix), LY_ENOTFOUND);
+    }
+
+    /* set value if none */
+    if (!val_str) {
+        val_str = "";
+    }
+
+    return lyd_create_meta(parent, meta, module, name, name_len, val_str, strlen(val_str), NULL, LY_VALUE_JSON,
+            NULL, LYD_HINT_DATA, parent ? parent->schema : NULL, clear_dflt, NULL);
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, ly_bool clear_dflt, const struct lyd_attr *attr,
+        struct lyd_meta **meta)
+{
+    const struct lys_module *mod;
+
+    LY_CHECK_ARG_RET(NULL, ctx, attr, parent || meta, LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(ctx, parent ? LYD_CTX(parent) : NULL, LY_EINVAL);
+
+    if (parent && !parent->schema) {
+        LOGERR(ctx, LY_EINVAL, "Cannot add metadata to an opaque node \"%s\".", ((struct lyd_node_opaq *)parent)->name);
+        return LY_EINVAL;
+    }
+    if (meta) {
+        *meta = NULL;
+    }
+
+    switch (attr->format) {
+    case LY_VALUE_XML:
+        mod = ly_ctx_get_module_implemented_ns(ctx, attr->name.module_ns);
+        if (!mod) {
+            LOGERR(ctx, LY_EINVAL, "Module with namespace \"%s\" not found.", attr->name.module_ns);
+            return LY_ENOTFOUND;
+        }
+        break;
+    case LY_VALUE_JSON:
+        mod = ly_ctx_get_module_implemented(ctx, attr->name.module_name);
+        if (!mod) {
+            LOGERR(ctx, LY_EINVAL, "Module \"%s\" not found.", attr->name.module_name);
+            return LY_ENOTFOUND;
+        }
+        break;
+    default:
+        LOGINT_RET(ctx);
+    }
+
+    return lyd_create_meta(parent, meta, mod, attr->name.name, strlen(attr->name.name), attr->value, strlen(attr->value),
+            NULL, attr->format, attr->val_prefix_data, attr->hints, parent ? parent->schema : NULL, clear_dflt, NULL);
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
+        const char *prefix, const char *module_name, struct lyd_node **node)
+{
+    struct lyd_node *ret = NULL;
+
+    LY_CHECK_ARG_RET(ctx, parent || ctx, parent || node, name, module_name, !prefix || !strcmp(prefix, module_name), LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(ctx, parent ? LYD_CTX(parent) : NULL, LY_EINVAL);
+
+    if (!ctx) {
+        ctx = LYD_CTX(parent);
+    }
+    if (!value) {
+        value = "";
+    }
+
+    LY_CHECK_RET(lyd_create_opaq(ctx, name, strlen(name), prefix, prefix ? strlen(prefix) : 0, module_name,
+            strlen(module_name), value, strlen(value), NULL, LY_VALUE_JSON, NULL, 0, &ret));
+    if (parent) {
+        lyd_insert_node(parent, NULL, ret, 1);
+    }
+
+    if (node) {
+        *node = ret;
+    }
+    return LY_SUCCESS;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
+        const char *prefix, const char *module_ns, struct lyd_node **node)
+{
+    struct lyd_node *ret = NULL;
+
+    LY_CHECK_ARG_RET(ctx, parent || ctx, parent || node, name, module_ns, LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(ctx, parent ? LYD_CTX(parent) : NULL, LY_EINVAL);
+
+    if (!ctx) {
+        ctx = LYD_CTX(parent);
+    }
+    if (!value) {
+        value = "";
+    }
+
+    LY_CHECK_RET(lyd_create_opaq(ctx, name, strlen(name), prefix, prefix ? strlen(prefix) : 0, module_ns,
+            strlen(module_ns), value, strlen(value), NULL, LY_VALUE_XML, NULL, 0, &ret));
+    if (parent) {
+        lyd_insert_node(parent, NULL, ret, 1);
+    }
+
+    if (node) {
+        *node = ret;
+    }
+    return LY_SUCCESS;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
+        struct lyd_attr **attr)
+{
+    struct lyd_attr *ret = NULL;
+    const struct ly_ctx *ctx;
+    const char *prefix, *tmp;
+    size_t pref_len, name_len, mod_len;
+
+    LY_CHECK_ARG_RET(NULL, parent, !parent->schema, name, LY_EINVAL);
+
+    ctx = LYD_CTX(parent);
+
+    /* parse the name */
+    tmp = name;
+    if (ly_parse_nodeid(&tmp, &prefix, &pref_len, &name, &name_len) || tmp[0]) {
+        LOGERR(ctx, LY_EINVAL, "Attribute name \"%s\" is not valid.", name);
+        return LY_EVALID;
+    }
+
+    if ((pref_len == 3) && !strncmp(prefix, "xml", 3)) {
+        /* not a prefix but special name */
+        name = prefix;
+        name_len += 1 + pref_len;
+        prefix = NULL;
+        pref_len = 0;
+    }
+
+    /* get the module */
+    if (module_name) {
+        mod_len = strlen(module_name);
+    } else {
+        module_name = prefix;
+        mod_len = pref_len;
+    }
+
+    /* set value if none */
+    if (!value) {
+        value = "";
+    }
+
+    LY_CHECK_RET(lyd_create_attr(parent, &ret, ctx, name, name_len, prefix, pref_len, module_name, mod_len, value,
+            strlen(value), NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA));
+
+    if (attr) {
+        *attr = ret;
+    }
+    return LY_SUCCESS;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
+        struct lyd_attr **attr)
+{
+    struct lyd_attr *ret = NULL;
+    const struct ly_ctx *ctx;
+    const char *prefix, *tmp;
+    size_t pref_len, name_len;
+
+    LY_CHECK_ARG_RET(NULL, parent, !parent->schema, name, LY_EINVAL);
+
+    ctx = LYD_CTX(parent);
+
+    /* parse the name */
+    tmp = name;
+    if (ly_parse_nodeid(&tmp, &prefix, &pref_len, &name, &name_len) || tmp[0]) {
+        LOGERR(ctx, LY_EINVAL, "Attribute name \"%s\" is not valid.", name);
+        return LY_EVALID;
+    }
+
+    if ((pref_len == 3) && !strncmp(prefix, "xml", 3)) {
+        /* not a prefix but special name */
+        name = prefix;
+        name_len += 1 + pref_len;
+        prefix = NULL;
+        pref_len = 0;
+    }
+
+    /* set value if none */
+    if (!value) {
+        value = "";
+    }
+
+    LY_CHECK_RET(lyd_create_attr(parent, &ret, ctx, name, name_len, prefix, pref_len, module_ns,
+            module_ns ? strlen(module_ns) : 0, value, strlen(value), NULL, LY_VALUE_XML, NULL, LYD_HINT_DATA));
+
+    if (attr) {
+        *attr = ret;
+    }
+    return LY_SUCCESS;
+}
+
+/**
+ * @brief Change the value of a term (leaf or leaf-list) node.
+ *
+ * Node changed this way is always considered explicitly set, meaning its default flag
+ * is always cleared.
+ *
+ * @param[in] term Term node to change.
+ * @param[in] value New value to set.
+ * @param[in] value_len Length of @p value.
+ * @param[in] format Format of @p value.
+ * @return LY_SUCCESS if value was changed,
+ * @return LY_EEXIST if value was the same and only the default flag was cleared,
+ * @return LY_ENOT if the values were equal and no change occured,
+ * @return LY_ERR value on other errors.
+ */
+static LY_ERR
+_lyd_change_term(struct lyd_node *term, const void *value, size_t value_len, LY_VALUE_FORMAT format)
+{
+    LY_ERR ret = LY_SUCCESS;
+    struct lysc_type *type;
+    struct lyd_node_term *t;
+    struct lyd_node *parent;
+    struct lyd_value val;
+    ly_bool dflt_change, val_change;
+
+    assert(term && term->schema && (term->schema->nodetype & LYD_NODE_TERM));
+
+    t = (struct lyd_node_term *)term;
+    type = ((struct lysc_node_leaf *)term->schema)->type;
+
+    /* parse the new value */
+    LOG_LOCSET(term->schema, term, NULL, NULL);
+    ret = lyd_value_store(LYD_CTX(term), &val, type, value, value_len, NULL, format, NULL, LYD_HINT_DATA, term->schema, NULL);
+    LOG_LOCBACK(term->schema ? 1 : 0, 1, 0, 0);
+    LY_CHECK_GOTO(ret, cleanup);
+
+    /* compare original and new value */
+    if (type->plugin->compare(&t->value, &val)) {
+        /* values differ, switch them */
+        type->plugin->free(LYD_CTX(term), &t->value);
+        t->value = val;
+        val_change = 1;
+    } else {
+        /* same values, free the new stored one */
+        type->plugin->free(LYD_CTX(term), &val);
+        val_change = 0;
+    }
+
+    /* always clear the default flag */
+    if (term->flags & LYD_DEFAULT) {
+        for (parent = term; parent; parent = lyd_parent(parent)) {
+            parent->flags &= ~LYD_DEFAULT;
+        }
+        dflt_change = 1;
+    } else {
+        dflt_change = 0;
+    }
+
+    if (val_change || dflt_change) {
+        /* make the node non-validated */
+        term->flags &= LYD_NEW;
+    }
+
+    if (val_change) {
+        if (term->schema->nodetype == LYS_LEAFLIST) {
+            /* leaf-list needs to be hashed again and re-inserted into parent */
+            lyd_unlink_hash(term);
+            lyd_hash(term);
+            LY_CHECK_GOTO(ret = lyd_insert_hash(term), cleanup);
+        } else if ((term->schema->flags & LYS_KEY) && term->parent) {
+            /* list needs to be updated if its key was changed */
+            assert(term->parent->schema->nodetype == LYS_LIST);
+            lyd_unlink_hash(lyd_parent(term));
+            lyd_hash(lyd_parent(term));
+            LY_CHECK_GOTO(ret = lyd_insert_hash(lyd_parent(term)), cleanup);
+        } /* else leaf that is not a key, its value is not used for its hash so it does not change */
+    }
+
+    /* retrun value */
+    if (!val_change) {
+        if (dflt_change) {
+            /* only default flag change */
+            ret = LY_EEXIST;
+        } else {
+            /* no change */
+            ret = LY_ENOT;
+        }
+    } /* else value changed, LY_SUCCESS */
+
+cleanup:
+    return ret;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_change_term(struct lyd_node *term, const char *val_str)
+{
+    LY_CHECK_ARG_RET(NULL, term, term->schema, term->schema->nodetype & LYD_NODE_TERM, LY_EINVAL);
+
+    return _lyd_change_term(term, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_JSON);
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_change_term_bin(struct lyd_node *term, const void *value, size_t value_len)
+{
+    LY_CHECK_ARG_RET(NULL, term, term->schema, term->schema->nodetype & LYD_NODE_TERM, LY_EINVAL);
+
+    return _lyd_change_term(term, value, value_len, LY_VALUE_LYB);
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_change_term_canon(struct lyd_node *term, const char *val_str)
+{
+    LY_CHECK_ARG_RET(NULL, term, term->schema, term->schema->nodetype & LYD_NODE_TERM, LY_EINVAL);
+
+    return _lyd_change_term(term, val_str, val_str ? strlen(val_str) : 0, LY_VALUE_CANON);
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_change_meta(struct lyd_meta *meta, const char *val_str)
+{
+    LY_ERR ret = LY_SUCCESS;
+    struct lyd_meta *m2 = NULL;
+    struct lyd_value val;
+    ly_bool val_change;
+
+    LY_CHECK_ARG_RET(NULL, meta, LY_EINVAL);
+
+    if (!val_str) {
+        val_str = "";
+    }
+
+    /* parse the new value into a new meta structure */
+    ret = lyd_create_meta(NULL, &m2, meta->annotation->module, meta->name, strlen(meta->name), val_str, strlen(val_str),
+            NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, meta->parent ? meta->parent->schema : NULL, 0, NULL);
+    LY_CHECK_GOTO(ret, cleanup);
+
+    /* compare original and new value */
+    if (lyd_compare_meta(meta, m2)) {
+        /* values differ, switch them */
+        val = meta->value;
+        meta->value = m2->value;
+        m2->value = val;
+        val_change = 1;
+    } else {
+        val_change = 0;
+    }
+
+    /* retrun value */
+    if (!val_change) {
+        /* no change */
+        ret = LY_ENOT;
+    } /* else value changed, LY_SUCCESS */
+
+cleanup:
+    lyd_free_meta_single(m2);
+    return ret;
+}
+
+/**
+ * @brief Update node value.
+ *
+ * @param[in] node Node to update.
+ * @param[in] value New value to set.
+ * @param[in] value_len Length of @p value.
+ * @param[in] value_type Type of @p value for anydata/anyxml node.
+ * @param[in] format Format of @p value.
+ * @param[out] new_parent Set to @p node if the value was updated, otherwise set to NULL.
+ * @param[out] new_node Set to @p node if the value was updated, otherwise set to NULL.
+ * @return LY_ERR value.
+ */
+static LY_ERR
+lyd_new_path_update(struct lyd_node *node, const void *value, size_t value_len, LYD_ANYDATA_VALUETYPE value_type,
+        LY_VALUE_FORMAT format, struct lyd_node **new_parent, struct lyd_node **new_node)
+{
+    LY_ERR ret = LY_SUCCESS;
+    struct lyd_node *new_any;
+
+    switch (node->schema->nodetype) {
+    case LYS_CONTAINER:
+    case LYS_NOTIF:
+    case LYS_RPC:
+    case LYS_ACTION:
+    case LYS_LIST:
+        /* if it exists, there is nothing to update */
+        *new_parent = NULL;
+        *new_node = NULL;
+        break;
+    case LYS_LEAFLIST:
+        if (!lysc_is_dup_inst_list(node->schema)) {
+            /* if it exists, there is nothing to update */
+            *new_parent = NULL;
+            *new_node = NULL;
+            break;
+        }
+    /* fallthrough */
+    case LYS_LEAF:
+        ret = _lyd_change_term(node, value, value_len, format);
+        if ((ret == LY_SUCCESS) || (ret == LY_EEXIST)) {
+            /* there was an actual change (at least of the default flag) */
+            *new_parent = node;
+            *new_node = node;
+            ret = LY_SUCCESS;
+        } else if (ret == LY_ENOT) {
+            /* no change */
+            *new_parent = NULL;
+            *new_node = NULL;
+            ret = LY_SUCCESS;
+        } /* else error */
+        break;
+    case LYS_ANYDATA:
+    case LYS_ANYXML:
+        /* create a new any node */
+        LY_CHECK_RET(lyd_create_any(node->schema, value, value_type, 0, &new_any));
+
+        /* compare with the existing one */
+        if (lyd_compare_single(node, new_any, 0)) {
+            /* not equal, switch values (so that we can use generic node free) */
+            ((struct lyd_node_any *)new_any)->value = ((struct lyd_node_any *)node)->value;
+            ((struct lyd_node_any *)new_any)->value_type = ((struct lyd_node_any *)node)->value_type;
+            ((struct lyd_node_any *)node)->value.str = value;
+            ((struct lyd_node_any *)node)->value_type = value_type;
+
+            *new_parent = node;
+            *new_node = node;
+        } else {
+            /* they are equal */
+            *new_parent = NULL;
+            *new_node = NULL;
+        }
+        lyd_free_tree(new_any);
+        break;
+    default:
+        LOGINT(LYD_CTX(node));
+        ret = LY_EINT;
+        break;
+    }
+
+    return ret;
+}
+
+static LY_ERR
+lyd_new_path_check_find_lypath(struct ly_path *path, const char *str_path, const char *value, size_t value_len,
+        LY_VALUE_FORMAT format, uint32_t options)
+{
+    LY_ERR r;
+    struct ly_path_predicate *pred;
+    struct lyd_value val;
+    const struct lysc_node *schema = NULL;
+    LY_ARRAY_COUNT_TYPE u, new_count;
+    int create = 0;
+
+    assert(path);
+
+    /* go through all the compiled nodes */
+    LY_ARRAY_FOR(path, u) {
+        schema = path[u].node;
+
+        if (lysc_is_dup_inst_list(schema)) {
+            if (path[u].pred_type == LY_PATH_PREDTYPE_NONE) {
+                /* creating a new key-less list or state leaf-list instance */
+                create = 1;
+                new_count = u;
+            } else if (path[u].pred_type != LY_PATH_PREDTYPE_POSITION) {
+                LOG_LOCSET(schema, NULL, NULL, NULL);
+                LOGVAL(schema->module->ctx, LYVE_XPATH, "Invalid predicate for %s \"%s\" in path \"%s\".",
+                        lys_nodetype2str(schema->nodetype), schema->name, str_path);
+                LOG_LOCBACK(1, 0, 0, 0);
+                return LY_EINVAL;
+            }
+        } else if ((schema->nodetype == LYS_LIST) && (path[u].pred_type != LY_PATH_PREDTYPE_LIST)) {
+            if ((u < LY_ARRAY_COUNT(path) - 1) || !(options & LYD_NEW_PATH_OPAQ)) {
+                LOG_LOCSET(schema, NULL, NULL, NULL);
+                LOGVAL(schema->module->ctx, LYVE_XPATH, "Predicate missing for %s \"%s\" in path \"%s\".",
+                        lys_nodetype2str(schema->nodetype), schema->name, str_path);
+                LOG_LOCBACK(1, 0, 0, 0);
+                return LY_EINVAL;
+            } /* else creating an opaque list */
+        } else if ((schema->nodetype == LYS_LEAFLIST) && (path[u].pred_type != LY_PATH_PREDTYPE_LEAFLIST)) {
+            r = LY_SUCCESS;
+            if (options & LYD_NEW_PATH_OPAQ) {
+                r = lyd_value_validate(NULL, schema, value, value_len, NULL, NULL, NULL);
+            }
+            if (!r) {
+                /* try to store the value */
+                LY_CHECK_RET(lyd_value_store(schema->module->ctx, &val, ((struct lysc_node_leaflist *)schema)->type,
+                        value, value_len, NULL, format, NULL, LYD_HINT_DATA, schema, NULL));
+                ++((struct lysc_type *)val.realtype)->refcount;
+
+                /* store the new predicate so that it is used when searching for this instance */
+                path[u].pred_type = LY_PATH_PREDTYPE_LEAFLIST;
+                LY_ARRAY_NEW_RET(schema->module->ctx, path[u].predicates, pred, LY_EMEM);
+                pred->value = val;
+            } /* else we have opaq flag and the value is not valid, leave no predicate and then create an opaque node */
+        }
+    }
+
+    if (create) {
+        /* hide the nodes that should always be created so they are not found */
+        while (new_count < LY_ARRAY_COUNT(path)) {
+            LY_ARRAY_DECREMENT(path);
+        }
+    }
+
+    return LY_SUCCESS;
+}
+
+/**
+ * @brief Create a new node in the data tree based on a path. All node types can be created.
+ *
+ * If @p path points to a list key, the key value from the predicate is used and @p value is ignored.
+ * Also, if a leaf-list is being created and both a predicate is defined in @p path
+ * and @p value is set, the predicate is preferred.
+ *
+ * For key-less lists and state leaf-lists, positional predicates can be used. If no preciate is used for these
+ * nodes, they are always created.
+ *
+ * @param[in] parent Data parent to add to/modify, can be NULL. Note that in case a first top-level sibling is used,
+ * it may no longer be first if @p path is absolute and starts with a non-existing top-level node inserted
+ * before @p parent. Use ::lyd_first_sibling() to adjust @p parent in these cases.
+ * @param[in] ctx libyang context, must be set if @p parent is NULL.
+ * @param[in] ext Extension instance where the node being created is defined. This argument takes effect only for absolute
+ * path or when the relative paths touches document root (top-level). In such cases the present extension instance replaces
+ * searching for the appropriate module.
+ * @param[in] path [Path](@ref howtoXPath) to create.
+ * @param[in] value Value of the new leaf/leaf-list (const char *) in ::LY_VALUE_JSON format. If creating an
+ * anyxml/anydata node, the expected type depends on @p value_type. For other node types, it should be NULL.
+ * @param[in] value_len Length of @p value in bytes. May be 0 if @p value is a zero-terminated string. Ignored when
+ * creating anyxml/anydata nodes.
+ * @param[in] value_type Anyxml/anydata node @p value type.
+ * @param[in] options Bitmask of options, see @ref pathoptions.
+ * @param[out] new_parent Optional first parent node created. If only one node was created, equals to @p new_node.
+ * @param[out] new_node Optional last node created.
+ * @return LY_ERR value.
+ */
+static LY_ERR
+lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const struct lysc_ext_instance *ext, const char *path,
+        const void *value, size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options,
+        struct lyd_node **new_parent, struct lyd_node **new_node)
+{
+    LY_ERR ret = LY_SUCCESS, r;
+    struct lyxp_expr *exp = NULL;
+    struct ly_path *p = NULL;
+    struct lyd_node *nparent = NULL, *nnode = NULL, *node = NULL, *cur_parent;
+    const struct lysc_node *schema;
+    const struct lyd_value *val = NULL;
+    LY_ARRAY_COUNT_TYPE path_idx = 0, orig_count = 0;
+    LY_VALUE_FORMAT format;
+
+    assert(parent || ctx);
+    assert(path && ((path[0] == '/') || parent));
+    assert(!(options & LYD_NEW_PATH_BIN_VALUE) || !(options & LYD_NEW_PATH_CANON_VALUE));
+
+    if (!ctx) {
+        ctx = LYD_CTX(parent);
+    }
+    if (value && !value_len) {
+        value_len = strlen(value);
+    }
+    if (options & LYD_NEW_PATH_BIN_VALUE) {
+        format = LY_VALUE_LYB;
+    } else if (options & LYD_NEW_PATH_CANON_VALUE) {
+        format = LY_VALUE_CANON;
+    } else {
+        format = LY_VALUE_JSON;
+    }
+
+    /* parse path */
+    LY_CHECK_GOTO(ret = ly_path_parse(ctx, NULL, path, strlen(path), 0, LY_PATH_BEGIN_EITHER, LY_PATH_PREFIX_OPTIONAL,
+            LY_PATH_PRED_SIMPLE, &exp), cleanup);
+
+    /* compile path */
+    LY_CHECK_GOTO(ret = ly_path_compile(ctx, NULL, lyd_node_schema(parent), ext, exp, options & LYD_NEW_PATH_OUTPUT ?
+            LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT, LY_PATH_TARGET_MANY, 0, LY_VALUE_JSON, NULL, &p), cleanup);
+
+    /* check the compiled path before searching existing nodes, it may be shortened */
+    orig_count = LY_ARRAY_COUNT(p);
+    LY_CHECK_GOTO(ret = lyd_new_path_check_find_lypath(p, path, value, value_len, format, options), cleanup);
+
+    /* try to find any existing nodes in the path */
+    if (parent) {
+        ret = ly_path_eval_partial(p, parent, &path_idx, &node);
+        if (ret == LY_SUCCESS) {
+            if (orig_count == LY_ARRAY_COUNT(p)) {
+                /* the node exists, are we supposed to update it or is it just a default? */
+                if (!(options & LYD_NEW_PATH_UPDATE) && !(node->flags & LYD_DEFAULT)) {
+                    LOG_LOCSET(NULL, node, NULL, NULL);
+                    LOGVAL(ctx, LYVE_REFERENCE, "Path \"%s\" already exists", path);
+                    LOG_LOCBACK(0, 1, 0, 0);
+                    ret = LY_EEXIST;
+                    goto cleanup;
+                }
+
+                /* update the existing node */
+                ret = lyd_new_path_update(node, value, value_len, value_type, format, &nparent, &nnode);
+                goto cleanup;
+            } /* else we were not searching for the whole path */
+        } else if (ret == LY_EINCOMPLETE) {
+            /* some nodes were found, adjust the iterator to the next segment */
+            ++path_idx;
+        } else if (ret == LY_ENOTFOUND) {
+            /* we will create the nodes from top-level, default behavior (absolute path), or from the parent (relative path) */
+            if (lysc_data_parent(p[0].node)) {
+                node = parent;
+            }
+        } else {
+            /* error */
+            goto cleanup;
+        }
+    }
+
+    /* restore the full path for creating new nodes */
+    while (orig_count > LY_ARRAY_COUNT(p)) {
+        LY_ARRAY_INCREMENT(p);
+    }
+
+    /* create all the non-existing nodes in a loop */
+    for ( ; path_idx < LY_ARRAY_COUNT(p); ++path_idx) {
+        cur_parent = node;
+        schema = p[path_idx].node;
+
+        switch (schema->nodetype) {
+        case LYS_LIST:
+            if (lysc_is_dup_inst_list(schema)) {
+                /* create key-less list instance */
+                LY_CHECK_GOTO(ret = lyd_create_inner(schema, &node), cleanup);
+            } else if ((options & LYD_NEW_PATH_OPAQ) && (p[path_idx].pred_type == LY_PATH_PREDTYPE_NONE)) {
+                /* creating opaque list without keys */
+                LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0,
+                        schema->module->name, strlen(schema->module->name), NULL, 0, NULL, LY_VALUE_JSON, NULL,
+                        LYD_NODEHINT_LIST, &node), cleanup);
+            } else {
+                /* create standard list instance */
+                assert(p[path_idx].pred_type == LY_PATH_PREDTYPE_LIST);
+                LY_CHECK_GOTO(ret = lyd_create_list(schema, p[path_idx].predicates, &node), cleanup);
+            }
+            break;
+        case LYS_CONTAINER:
+        case LYS_NOTIF:
+        case LYS_RPC:
+        case LYS_ACTION:
+            LY_CHECK_GOTO(ret = lyd_create_inner(schema, &node), cleanup);
+            break;
+        case LYS_LEAFLIST:
+            if ((options & LYD_NEW_PATH_OPAQ) && (p[path_idx].pred_type != LY_PATH_PREDTYPE_LEAFLIST)) {
+                /* we have not checked this only for dup-inst lists, otherwise it must be opaque */
+                r = LY_EVALID;
+                if (lysc_is_dup_inst_list(schema)) {
+                    /* validate value */
+                    r = lyd_value_validate(NULL, schema, value ? value : "", value_len, NULL, NULL, NULL);
+                }
+                if (r && (r != LY_EINCOMPLETE)) {
+                    /* creating opaque leaf-list */
+                    LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), value, value_len,
+                            schema->module->name, strlen(schema->module->name), NULL, 0, NULL, format, NULL,
+                            LYD_NODEHINT_LEAFLIST, &node), cleanup);
+                    break;
+                }
+            }
+
+            /* get value to set */
+            if (p[path_idx].pred_type == LY_PATH_PREDTYPE_LEAFLIST) {
+                val = &p[path_idx].predicates[0].value;
+            }
+
+            /* create a leaf-list instance */
+            if (val) {
+                LY_CHECK_GOTO(ret = lyd_create_term2(schema, &p[path_idx].predicates[0].value, &node), cleanup);
+            } else {
+                LY_CHECK_GOTO(ret = lyd_create_term(schema, value, value_len, NULL, format, NULL, LYD_HINT_DATA,
+                        NULL, &node), cleanup);
+            }
+            break;
+        case LYS_LEAF:
+            if (lysc_is_key(schema) && cur_parent->schema) {
+                /* it must have been already created or some error will occur later */
+                lyd_find_sibling_schema(lyd_child(cur_parent), schema, &node);
+                assert(node);
+                goto next_iter;
+            }
+
+            if (options & LYD_NEW_PATH_OPAQ) {
+                if (cur_parent && !cur_parent->schema) {
+                    /* always create opaque nodes for opaque parents */
+                    r = LY_ENOT;
+                } else {
+                    /* validate value */
+                    r = lyd_value_validate(NULL, schema, value ? value : "", value_len, NULL, NULL, NULL);
+                }
+                if (r && (r != LY_EINCOMPLETE)) {
+                    /* creating opaque leaf */
+                    LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), value, value_len,
+                            schema->module->name, strlen(schema->module->name), NULL, 0, NULL, format, NULL, 0, &node),
+                            cleanup);
+                    break;
+                }
+            }
+
+            /* create a leaf instance */
+            LY_CHECK_GOTO(ret = lyd_create_term(schema, value, value_len, NULL, format, NULL, LYD_HINT_DATA, NULL,
+                    &node), cleanup);
+            break;
+        case LYS_ANYDATA:
+        case LYS_ANYXML:
+            LY_CHECK_GOTO(ret = lyd_create_any(schema, value, value_type, 0, &node), cleanup);
+            break;
+        default:
+            LOGINT(ctx);
+            ret = LY_EINT;
+            goto cleanup;
+        }
+
+        if (p[path_idx].ext) {
+            node->flags |= LYD_EXT;
+        }
+        if (cur_parent) {
+            /* connect to the parent */
+            lyd_insert_node(cur_parent, NULL, node, 0);
+        } else if (parent) {
+            /* connect to top-level siblings */
+            lyd_insert_node(NULL, &parent, node, 0);
+        }
+
+next_iter:
+        /* update remembered nodes */
+        if (!nparent) {
+            nparent = node;
+        }
+        nnode = node;
+    }
+
+cleanup:
+    lyxp_expr_free(ctx, exp);
+    if (p) {
+        while (orig_count > LY_ARRAY_COUNT(p)) {
+            LY_ARRAY_INCREMENT(p);
+        }
+    }
+    ly_path_free(ctx, p);
+    if (!ret) {
+        /* set out params only on success */
+        if (new_parent) {
+            *new_parent = nparent;
+        }
+        if (new_node) {
+            *new_node = nnode;
+        }
+    } else {
+        lyd_free_tree(nparent);
+    }
+    return ret;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value, uint32_t options,
+        struct lyd_node **node)
+{
+    LY_CHECK_ARG_RET(ctx, parent || ctx, path, (path[0] == '/') || parent,
+            !(options & LYD_NEW_PATH_BIN_VALUE) || !(options & LYD_NEW_PATH_CANON_VALUE), LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, ctx, LY_EINVAL);
+
+    return lyd_new_path_(parent, ctx, NULL, path, value, 0, LYD_ANYDATA_STRING, options, node, NULL);
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
+        size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent,
+        struct lyd_node **new_node)
+{
+    LY_CHECK_ARG_RET(ctx, parent || ctx, path, (path[0] == '/') || parent,
+            !(options & LYD_NEW_PATH_BIN_VALUE) || !(options & LYD_NEW_PATH_CANON_VALUE), LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, ctx, LY_EINVAL);
+
+    return lyd_new_path_(parent, ctx, NULL, path, value, value_len, value_type, options, new_parent, new_node);
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path, const void *value,
+        uint32_t options, struct lyd_node **node)
+{
+    const struct ly_ctx *ctx = ext ? ext->module->ctx : NULL;
+
+    LY_CHECK_ARG_RET(ctx, ext, path, (path[0] == '/') || parent,
+            !(options & LYD_NEW_PATH_BIN_VALUE) || !(options & LYD_NEW_PATH_CANON_VALUE), LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, ctx, LY_EINVAL);
+
+    return lyd_new_path_(parent, ctx, ext, path, value, 0, LYD_ANYDATA_STRING, options, node, NULL);
+}
+
+LY_ERR
+lyd_new_implicit_r(struct lyd_node *parent, struct lyd_node **first, const struct lysc_node *sparent,
+        const struct lys_module *mod, struct ly_set *node_when, struct ly_set *node_types, uint32_t impl_opts,
+        struct lyd_node **diff)
+{
+    LY_ERR ret;
+    const struct lysc_node *iter = NULL;
+    struct lyd_node *node = NULL;
+    struct lyd_value **dflts;
+    LY_ARRAY_COUNT_TYPE u;
+    uint32_t getnext_opts;
+
+    assert(first && (parent || sparent || mod));
+
+    if (!sparent && parent) {
+        sparent = parent->schema;
+    }
+
+    getnext_opts = LYS_GETNEXT_WITHCHOICE;
+    if (impl_opts & LYD_IMPLICIT_OUTPUT) {
+        getnext_opts |= LYS_GETNEXT_OUTPUT;
+    }
+
+    while ((iter = lys_getnext(iter, sparent, mod ? mod->compiled : NULL, getnext_opts))) {
+        if ((impl_opts & LYD_IMPLICIT_NO_STATE) && (iter->flags & LYS_CONFIG_R)) {
+            continue;
+        } else if ((impl_opts & LYD_IMPLICIT_NO_CONFIG) && (iter->flags & LYS_CONFIG_W)) {
+            continue;
+        }
+
+        switch (iter->nodetype) {
+        case LYS_CHOICE:
+            node = lys_getnext_data(NULL, *first, NULL, iter, NULL);
+            if (!node && ((struct lysc_node_choice *)iter)->dflt) {
+                /* create default case data */
+                LY_CHECK_RET(lyd_new_implicit_r(parent, first, &((struct lysc_node_choice *)iter)->dflt->node,
+                        NULL, node_when, node_types, impl_opts, diff));
+            } else if (node) {
+                /* create any default data in the existing case */
+                assert(node->schema->parent->nodetype == LYS_CASE);
+                LY_CHECK_RET(lyd_new_implicit_r(parent, first, node->schema->parent, NULL, node_when, node_types,
+                        impl_opts, diff));
+            }
+            break;
+        case LYS_CONTAINER:
+            if (!(iter->flags & LYS_PRESENCE) && lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
+                /* create default NP container */
+                LY_CHECK_RET(lyd_create_inner(iter, &node));
+                node->flags = LYD_DEFAULT | (lysc_has_when(iter) ? LYD_WHEN_TRUE : 0);
+                lyd_insert_node(parent, first, node, 0);
+
+                if (lysc_has_when(iter) && node_when) {
+                    /* remember to resolve when */
+                    LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
+                }
+                if (diff) {
+                    /* add into diff */
+                    LY_CHECK_RET(lyd_val_diff_add(node, LYD_DIFF_OP_CREATE, diff));
+                }
+
+                /* create any default children */
+                LY_CHECK_RET(lyd_new_implicit_r(node, lyd_node_child_p(node), NULL, NULL, node_when, node_types,
+                        impl_opts, diff));
+            }
+            break;
+        case LYS_LEAF:
+            if (!(impl_opts & LYD_IMPLICIT_NO_DEFAULTS) && ((struct lysc_node_leaf *)iter)->dflt &&
+                    lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
+                /* create default leaf */
+                ret = lyd_create_term2(iter, ((struct lysc_node_leaf *)iter)->dflt, &node);
+                if (ret == LY_EINCOMPLETE) {
+                    if (node_types) {
+                        /* remember to resolve type */
+                        LY_CHECK_RET(ly_set_add(node_types, node, 1, NULL));
+                    }
+                } else if (ret) {
+                    return ret;
+                }
+                node->flags = LYD_DEFAULT | (lysc_has_when(iter) ? LYD_WHEN_TRUE : 0);
+                lyd_insert_node(parent, first, node, 0);
+
+                if (lysc_has_when(iter) && node_when) {
+                    /* remember to resolve when */
+                    LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
+                }
+                if (diff) {
+                    /* add into diff */
+                    LY_CHECK_RET(lyd_val_diff_add(node, LYD_DIFF_OP_CREATE, diff));
+                }
+            }
+            break;
+        case LYS_LEAFLIST:
+            if (!(impl_opts & LYD_IMPLICIT_NO_DEFAULTS) && ((struct lysc_node_leaflist *)iter)->dflts &&
+                    lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
+                /* create all default leaf-lists */
+                dflts = ((struct lysc_node_leaflist *)iter)->dflts;
+                LY_ARRAY_FOR(dflts, u) {
+                    ret = lyd_create_term2(iter, dflts[u], &node);
+                    if (ret == LY_EINCOMPLETE) {
+                        if (node_types) {
+                            /* remember to resolve type */
+                            LY_CHECK_RET(ly_set_add(node_types, node, 1, NULL));
+                        }
+                    } else if (ret) {
+                        return ret;
+                    }
+                    node->flags = LYD_DEFAULT | (lysc_has_when(iter) ? LYD_WHEN_TRUE : 0);
+                    lyd_insert_node(parent, first, node, 0);
+
+                    if (lysc_has_when(iter) && node_when) {
+                        /* remember to resolve when */
+                        LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
+                    }
+                    if (diff) {
+                        /* add into diff */
+                        LY_CHECK_RET(lyd_val_diff_add(node, LYD_DIFF_OP_CREATE, diff));
+                    }
+                }
+            }
+            break;
+        default:
+            /* without defaults */
+            break;
+        }
+    }
+
+    return LY_SUCCESS;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff)
+{
+    LY_ERR ret = LY_SUCCESS;
+    struct lyd_node *node;
+    struct ly_set node_when = {0};
+
+    LY_CHECK_ARG_RET(NULL, tree, LY_EINVAL);
+    if (diff) {
+        *diff = NULL;
+    }
+
+    LYD_TREE_DFS_BEGIN(tree, node) {
+        /* skip added default nodes */
+        if (((node->flags & (LYD_DEFAULT | LYD_NEW)) != (LYD_DEFAULT | LYD_NEW)) &&
+                (node->schema->nodetype & LYD_NODE_INNER)) {
+            LY_CHECK_GOTO(ret = lyd_new_implicit_r(node, lyd_node_child_p(node), NULL, NULL, &node_when, NULL,
+                    implicit_options, diff), cleanup);
+        }
+
+        LYD_TREE_DFS_END(tree, node);
+    }
+
+    /* resolve when and remove any invalid defaults */
+    LY_CHECK_GOTO(ret = lyd_validate_unres(&tree, NULL, &node_when, LYXP_IGNORE_WHEN, NULL, NULL, NULL, 0, diff), cleanup);
+
+cleanup:
+    ly_set_erase(&node_when, NULL);
+    if (ret && diff) {
+        lyd_free_all(*diff);
+        *diff = NULL;
+    }
+    return ret;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options, struct lyd_node **diff)
+{
+    const struct lys_module *mod;
+    struct lyd_node *d = NULL;
+    uint32_t i = 0;
+    LY_ERR ret = LY_SUCCESS;
+
+    LY_CHECK_ARG_RET(ctx, tree, *tree || ctx, LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(*tree ? LYD_CTX(*tree) : NULL, ctx, LY_EINVAL);
+    if (diff) {
+        *diff = NULL;
+    }
+    if (!ctx) {
+        ctx = LYD_CTX(*tree);
+    }
+
+    /* add nodes for each module one-by-one */
+    while ((mod = ly_ctx_get_module_iter(ctx, &i))) {
+        if (!mod->implemented) {
+            continue;
+        }
+
+        LY_CHECK_GOTO(ret = lyd_new_implicit_module(tree, mod, implicit_options, diff ? &d : NULL), cleanup);
+        if (d) {
+            /* merge into one diff */
+            lyd_insert_sibling(*diff, d, diff);
+
+            d = NULL;
+        }
+    }
+
+cleanup:
+    if (ret && diff) {
+        lyd_free_all(*diff);
+        *diff = NULL;
+    }
+    return ret;
+}
+
+LIBYANG_API_DEF LY_ERR
+lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module, uint32_t implicit_options,
+        struct lyd_node **diff)
+{
+    LY_ERR ret = LY_SUCCESS;
+    struct lyd_node *root, *d = NULL;
+    struct ly_set node_when = {0};
+
+    LY_CHECK_ARG_RET(NULL, tree, module, LY_EINVAL);
+    LY_CHECK_CTX_EQUAL_RET(*tree ? LYD_CTX(*tree) : NULL, module ? module->ctx : NULL, LY_EINVAL);
+    if (diff) {
+        *diff = NULL;
+    }
+
+    /* add all top-level defaults for this module */
+    LY_CHECK_GOTO(ret = lyd_new_implicit_r(NULL, tree, NULL, module, &node_when, NULL, implicit_options, diff), cleanup);
+
+    /* resolve when and remove any invalid defaults */
+    LY_CHECK_GOTO(ret = lyd_validate_unres(tree, module, &node_when, LYXP_IGNORE_WHEN, NULL, NULL, NULL, 0, diff),
+            cleanup);
+
+    /* process nested nodes */
+    LY_LIST_FOR(*tree, root) {
+        /* skip added default nodes */
+        if ((root->flags & (LYD_DEFAULT | LYD_NEW)) != (LYD_DEFAULT | LYD_NEW)) {
+            LY_CHECK_GOTO(ret = lyd_new_implicit_tree(root, implicit_options, diff ? &d : NULL), cleanup);
+
+            if (d) {
+                /* merge into one diff */
+                lyd_insert_sibling(*diff, d, diff);
+
+                d = NULL;
+            }
+        }
+    }
+
+cleanup:
+    ly_set_erase(&node_when, NULL);
+    if (ret && diff) {
+        lyd_free_all(*diff);
+        *diff = NULL;
+    }
+    return ret;
+}
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_common.c
similarity index 99%
rename from src/tree_schema_helpers.c
rename to src/tree_schema_common.c
index 42aa112..7ba1b23 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_common.c
@@ -1,9 +1,10 @@
 /**
- * @file tree_schema_helpers.c
+ * @file tree_schema_common.c
  * @author Radek Krejci <rkrejci@cesnet.cz>
- * @brief Parsing and validation helper functions for schema trees
+ * @author Michal Vasko <mvasko@cesnet.cz>
+ * @brief Parsing and validation common functions for schema trees
  *
- * Copyright (c) 2015 - 2018 CESNET, z.s.p.o.
+ * Copyright (c) 2015 - 2022 CESNET, z.s.p.o.
  *
  * This source code is licensed under BSD 3-Clause License (the "License").
  * You may not use this file except in compliance with the License.
