parser REFACTOR move parser functions
diff --git a/src/parser_common.c b/src/parser_common.c
index 5c345bb..3660b96 100644
--- a/src/parser_common.c
+++ b/src/parser_common.c
@@ -213,6 +213,77 @@
     return LY_SUCCESS;
 }
 
+LY_ERR
+lyd_parse_check_keys(struct lyd_node *node)
+{
+    const struct lysc_node *skey = NULL;
+    const struct lyd_node *key;
+
+    assert(node->schema->nodetype == LYS_LIST);
+
+    key = lyd_child(node);
+    while ((skey = lys_getnext(skey, node->schema, NULL, 0)) && (skey->flags & LYS_KEY)) {
+        if (!key || (key->schema != skey)) {
+            LOGVAL(LYD_CTX(node), LY_VCODE_NOKEY, skey->name);
+            return LY_EVALID;
+        }
+
+        key = key->next;
+    }
+
+    return LY_SUCCESS;
+}
+
+LY_ERR
+lyd_parse_set_data_flags(struct lyd_node *node, struct lyd_meta **meta, struct lyd_ctx *lydctx,
+        struct lysc_ext_instance *ext)
+{
+    struct lyd_meta *meta2, *prev_meta = NULL;
+    struct lyd_ctx_ext_val *ext_val;
+
+    if (lysc_has_when(node->schema)) {
+        if (!(lydctx->parse_opts & LYD_PARSE_ONLY)) {
+            /* remember we need to evaluate this node's when */
+            LY_CHECK_RET(ly_set_add(&lydctx->node_when, node, 1, NULL));
+        }
+    }
+
+    LY_LIST_FOR(*meta, meta2) {
+        if (!strcmp(meta2->name, "default") && !strcmp(meta2->annotation->module->name, "ietf-netconf-with-defaults") &&
+                meta2->value.boolean) {
+            /* node is default according to the metadata */
+            node->flags |= LYD_DEFAULT;
+
+            /* delete the metadata */
+            if (prev_meta) {
+                prev_meta->next = meta2->next;
+            } else {
+                *meta = (*meta)->next;
+            }
+            lyd_free_meta_single(meta2);
+            break;
+        }
+
+        prev_meta = meta2;
+    }
+
+    if (ext) {
+        /* parsed for an extension */
+        node->flags |= LYD_EXT;
+
+        if (!(lydctx->parse_opts & LYD_PARSE_ONLY)) {
+            /* rememeber for validation */
+            ext_val = malloc(sizeof *ext_val);
+            LY_CHECK_ERR_RET(!ext_val, LOGMEM(LYD_CTX(node)), LY_EMEM);
+            ext_val->ext = ext;
+            ext_val->sibling = node;
+            LY_CHECK_RET(ly_set_add(&lydctx->ext_val, ext_val, 1, NULL));
+        }
+    }
+
+    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,
diff --git a/src/parser_internal.h b/src/parser_internal.h
index 67baeed..5cae45b 100644
--- a/src/parser_internal.h
+++ b/src/parser_internal.h
@@ -323,4 +323,25 @@
         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);
 
+/**
+ * @brief Check that a list has all its keys.
+ *
+ * @param[in] node List to check.
+ * @return LY_SUCCESS on success.
+ * @return LY_ENOT on a missing key.
+ */
+LY_ERR lyd_parse_check_keys(struct lyd_node *node);
+
+/**
+ * @brief Set data flags for a newly parsed node.
+ *
+ * @param[in] node Node to use.
+ * @param[in,out] meta Node metadata, may be removed from.
+ * @param[in] lydctx Data parsing context.
+ * @param[in] ext Extension instance if @p node was parsed for one.
+ * @return LY_ERR value.
+ */
+LY_ERR lyd_parse_set_data_flags(struct lyd_node *node, struct lyd_meta **meta, struct lyd_ctx *lydctx,
+        struct lysc_ext_instance *ext);
+
 #endif /* LY_PARSER_INTERNAL_H_ */
diff --git a/src/tree_data_common.c b/src/tree_data_common.c
index 51035fb..8f087b2 100644
--- a/src/tree_data_common.c
+++ b/src/tree_data_common.c
@@ -384,77 +384,6 @@
 }
 
 LY_ERR
-lyd_parse_check_keys(struct lyd_node *node)
-{
-    const struct lysc_node *skey = NULL;
-    const struct lyd_node *key;
-
-    assert(node->schema->nodetype == LYS_LIST);
-
-    key = lyd_child(node);
-    while ((skey = lys_getnext(skey, node->schema, NULL, 0)) && (skey->flags & LYS_KEY)) {
-        if (!key || (key->schema != skey)) {
-            LOGVAL(LYD_CTX(node), LY_VCODE_NOKEY, skey->name);
-            return LY_EVALID;
-        }
-
-        key = key->next;
-    }
-
-    return LY_SUCCESS;
-}
-
-LY_ERR
-lyd_parse_set_data_flags(struct lyd_node *node, struct lyd_meta **meta, struct lyd_ctx *lydctx,
-        struct lysc_ext_instance *ext)
-{
-    struct lyd_meta *meta2, *prev_meta = NULL;
-    struct lyd_ctx_ext_val *ext_val;
-
-    if (lysc_has_when(node->schema)) {
-        if (!(lydctx->parse_opts & LYD_PARSE_ONLY)) {
-            /* remember we need to evaluate this node's when */
-            LY_CHECK_RET(ly_set_add(&lydctx->node_when, node, 1, NULL));
-        }
-    }
-
-    LY_LIST_FOR(*meta, meta2) {
-        if (!strcmp(meta2->name, "default") && !strcmp(meta2->annotation->module->name, "ietf-netconf-with-defaults") &&
-                meta2->value.boolean) {
-            /* node is default according to the metadata */
-            node->flags |= LYD_DEFAULT;
-
-            /* delete the metadata */
-            if (prev_meta) {
-                prev_meta->next = meta2->next;
-            } else {
-                *meta = (*meta)->next;
-            }
-            lyd_free_meta_single(meta2);
-            break;
-        }
-
-        prev_meta = meta2;
-    }
-
-    if (ext) {
-        /* parsed for an extension */
-        node->flags |= LYD_EXT;
-
-        if (!(lydctx->parse_opts & LYD_PARSE_ONLY)) {
-            /* rememeber for validation */
-            ext_val = malloc(sizeof *ext_val);
-            LY_CHECK_ERR_RET(!ext_val, LOGMEM(LYD_CTX(node)), LY_EMEM);
-            ext_val->ext = ext;
-            ext_val->sibling = node;
-            LY_CHECK_RET(ly_set_add(&lydctx->ext_val, ext_val, 1, NULL));
-        }
-    }
-
-    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)
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index 0e45bcb..408b3db 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -117,27 +117,6 @@
 const struct lys_module *lyd_data_next_module(struct lyd_node **next, struct lyd_node **first);
 
 /**
- * @brief Check that a list has all its keys.
- *
- * @param[in] node List to check.
- * @return LY_SUCCESS on success.
- * @return LY_ENOT on a missing key.
- */
-LY_ERR lyd_parse_check_keys(struct lyd_node *node);
-
-/**
- * @brief Set data flags for a newly parsed node.
- *
- * @param[in] node Node to use.
- * @param[in,out] meta Node metadata, may be removed from.
- * @param[in] lydctx Data parsing context.
- * @param[in] ext Extension instance if @p node was parsed for one.
- * @return LY_ERR value.
- */
-LY_ERR lyd_parse_set_data_flags(struct lyd_node *node, struct lyd_meta **meta, struct lyd_ctx *lydctx,
-        struct lysc_ext_instance *ext);
-
-/**
  * @brief Get schema node of a data node. Useful especially for opaque nodes.
  *
  * @param[in] node Data node to use.