schema REFACTOR unify functions to search on schema tree

- rename ly_ctx_get_node() to lys_find_path()
- rename lys_find_path_atoms() to lys_find_lypath_atoms()
- implement new lys_find_path_atoms() as a wrapper around
lys_find_lypath_atoms()
diff --git a/src/context.c b/src/context.c
index 3986997..a9deed8 100644
--- a/src/context.c
+++ b/src/context.c
@@ -543,40 +543,6 @@
     return NULL;
 }
 
-API const struct lysc_node *
-ly_ctx_get_node(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path, ly_bool output)
-{
-    const struct lysc_node *snode = NULL;
-    struct lyxp_expr *exp = NULL;
-    struct ly_path *p = NULL;
-    LY_ERR ret;
-    uint8_t oper;
-
-    LY_CHECK_ARG_RET(ctx, ctx || ctx_node, NULL);
-
-    if (!ctx) {
-        ctx = ctx_node->module->ctx;
-    }
-
-    /* parse */
-    ret = lyxp_expr_parse(ctx, path, strlen(path), 0, &exp);
-    LY_CHECK_GOTO(ret, cleanup);
-
-    /* compile */
-    oper = output ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT;
-    ret = ly_path_compile(ctx, NULL, ctx_node, exp, LY_PATH_LREF_FALSE, oper, LY_PATH_TARGET_MANY,
-            LY_PREF_JSON, NULL, &p);
-    LY_CHECK_GOTO(ret, cleanup);
-
-    /* get last node */
-    snode = p[LY_ARRAY_COUNT(p) - 1].node;
-
-cleanup:
-    ly_path_free(ctx, p);
-    lyxp_expr_free(ctx, exp);
-    return snode;
-}
-
 API void
 ly_ctx_reset_latests(struct ly_ctx *ctx)
 {
diff --git a/src/context.h b/src/context.h
index 6b720c4..8ecea1e 100644
--- a/src/context.h
+++ b/src/context.h
@@ -419,18 +419,6 @@
 struct lys_module *ly_ctx_get_module_implemented_ns(const struct ly_ctx *ctx, const char *ns);
 
 /**
- * @brief Get a schema node based on the given data path (JSON format, see @ref howtoXPath).
- *
- * @param[in] ctx libyang context, set for absolute paths.
- * @param[in] ctx_node Starting context node for a relative data path, set for relative paths.
- * @param[in] path JSON path of the node to get.
- * @param[in] output Search operation output instead of input.
- * @return Found schema node or NULL.
- */
-const struct lysc_node *ly_ctx_get_node(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path,
-        ly_bool output);
-
-/**
  * @brief Reset cached latest revision information of the schemas in the context.
  *
  * When a (sub)module is imported/included without revision, the latest revision is
diff --git a/src/tree_schema.c b/src/tree_schema.c
index e933995..dbf5495 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -352,36 +352,6 @@
 }
 
 API LY_ERR
-lys_find_path_atoms(const struct ly_path *path, struct ly_set **set)
-{
-    LY_ERR ret = LY_SUCCESS;
-    LY_ARRAY_COUNT_TYPE u, v;
-
-    LY_CHECK_ARG_RET(NULL, path, set, LY_EINVAL);
-
-    /* allocate return set */
-    LY_CHECK_RET(ly_set_new(set));
-
-    LY_ARRAY_FOR(path, u) {
-        /* add nodes from the path */
-        LY_CHECK_GOTO(ret = ly_set_add(*set, (void *)path[u].node, 0, NULL), cleanup);
-        if (path[u].pred_type == LY_PATH_PREDTYPE_LIST) {
-            LY_ARRAY_FOR(path[u].predicates, v) {
-                /* add all the keys in a predicate */
-                LY_CHECK_GOTO(ret = ly_set_add(*set, (void *)path[u].predicates[v].key, 0, NULL), cleanup);
-            }
-        }
-    }
-
-cleanup:
-    if (ret) {
-        ly_set_free(*set, NULL);
-        *set = NULL;
-    }
-    return ret;
-}
-
-API LY_ERR
 lys_find_expr_atoms(const struct lysc_node *ctx_node, const struct lys_module *cur_mod, const struct lyxp_expr *expr,
         const struct lysc_prefix *prefixes, uint32_t options, struct ly_set **set)
 {
@@ -470,6 +440,104 @@
     return ret;
 }
 
+API LY_ERR
+lys_find_lypath_atoms(const struct ly_path *path, struct ly_set **set)
+{
+    LY_ERR ret = LY_SUCCESS;
+    LY_ARRAY_COUNT_TYPE u, v;
+
+    LY_CHECK_ARG_RET(NULL, path, set, LY_EINVAL);
+
+    /* allocate return set */
+    LY_CHECK_RET(ly_set_new(set));
+
+    LY_ARRAY_FOR(path, u) {
+        /* add nodes from the path */
+        LY_CHECK_GOTO(ret = ly_set_add(*set, (void *)path[u].node, 0, NULL), cleanup);
+        if (path[u].pred_type == LY_PATH_PREDTYPE_LIST) {
+            LY_ARRAY_FOR(path[u].predicates, v) {
+                /* add all the keys in a predicate */
+                LY_CHECK_GOTO(ret = ly_set_add(*set, (void *)path[u].predicates[v].key, 0, NULL), cleanup);
+            }
+        }
+    }
+
+cleanup:
+    if (ret) {
+        ly_set_free(*set, NULL);
+        *set = NULL;
+    }
+    return ret;
+}
+
+API LY_ERR
+lys_find_path_atoms(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path, ly_bool output,
+        struct ly_set **set)
+{
+    LY_ERR ret = LY_SUCCESS;
+    uint8_t oper;
+    struct lyxp_expr *expr = NULL;
+    struct ly_path *p = NULL;
+
+    LY_CHECK_ARG_RET(ctx, ctx || ctx_node, path, set, LY_EINVAL);
+
+    if (!ctx) {
+        ctx = ctx_node->module->ctx;
+    }
+
+    /* parse */
+    ret = lyxp_expr_parse(ctx, path, strlen(path), 0, &expr);
+    LY_CHECK_GOTO(ret, cleanup);
+
+    /* compile */
+    oper = output ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT;
+    ret = ly_path_compile(ctx, NULL, ctx_node, expr, LY_PATH_LREF_FALSE, oper, LY_PATH_TARGET_MANY,
+            LY_PREF_JSON, NULL, &p);
+    LY_CHECK_GOTO(ret, cleanup);
+
+    /* resolve */
+    ret = lys_find_lypath_atoms(p, set);
+
+cleanup:
+    ly_path_free(ctx, p);
+    lyxp_expr_free(ctx, expr);
+    return ret;
+}
+
+API const struct lysc_node *
+lys_find_path(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path, ly_bool output)
+{
+    const struct lysc_node *snode = NULL;
+    struct lyxp_expr *exp = NULL;
+    struct ly_path *p = NULL;
+    LY_ERR ret;
+    uint8_t oper;
+
+    LY_CHECK_ARG_RET(ctx, ctx || ctx_node, NULL);
+
+    if (!ctx) {
+        ctx = ctx_node->module->ctx;
+    }
+
+    /* parse */
+    ret = lyxp_expr_parse(ctx, path, strlen(path), 0, &exp);
+    LY_CHECK_GOTO(ret, cleanup);
+
+    /* compile */
+    oper = output ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT;
+    ret = ly_path_compile(ctx, NULL, ctx_node, exp, LY_PATH_LREF_FALSE, oper, LY_PATH_TARGET_MANY,
+            LY_PREF_JSON, NULL, &p);
+    LY_CHECK_GOTO(ret, cleanup);
+
+    /* get last node */
+    snode = p[LY_ARRAY_COUNT(p) - 1].node;
+
+cleanup:
+    ly_path_free(ctx, p);
+    lyxp_expr_free(ctx, exp);
+    return snode;
+}
+
 char *
 lysc_path_until(const struct lysc_node *node, const struct lysc_node *parent, LYSC_PATH_TYPE pathtype, char *buffer,
         size_t buflen)
diff --git a/src/tree_schema.h b/src/tree_schema.h
index da42042..4813d23 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -1940,16 +1940,6 @@
 LY_ERR lys_find_xpath_atoms(const struct lysc_node *ctx_node, const char *xpath, uint32_t options, struct ly_set **set);
 
 /**
- * @brief Get all the schema nodes that are required for @p path to be evaluated (atoms).
- *
- * @param[in] path Compiled path to use.
- * @param[out] set Set of found atoms (schema nodes).
- * @return LY_SUCCESS on success, @p set is returned.
- * @return LY_ERR value on error.
- */
-LY_ERR lys_find_path_atoms(const struct ly_path *path, struct ly_set **set);
-
-/**
  * @brief Get all the schema nodes that are required for @p expr to be evaluated (atoms).
  *
  * @param[in] ctx_node XPath schema context node.
@@ -1977,6 +1967,41 @@
 LY_ERR lys_find_xpath(const struct lysc_node *ctx_node, const char *xpath, uint32_t options, struct ly_set **set);
 
 /**
+ * @brief Get all the schema nodes that are required for @p path to be evaluated (atoms).
+ *
+ * @param[in] path Compiled path to use.
+ * @param[out] set Set of found atoms (schema nodes).
+ * @return LY_SUCCESS on success, @p set is returned.
+ * @return LY_ERR value on error.
+ */
+LY_ERR lys_find_lypath_atoms(const struct ly_path *path, struct ly_set **set);
+
+/**
+ * @brief Get all the schema nodes that are required for @p path to be evaluated (atoms).
+ *
+ * @param[in] ctx libyang context, set for absolute paths.
+ * @param[in] ctx_node Starting context node for a relative data path, set for relative paths.
+ * @param[in] path JSON path to examine.
+ * @param[in] output Search operation output instead of input.
+ * @param[out] set Set of found atoms (schema nodes).
+ * @return LY_ERR value on error.
+ */
+LY_ERR lys_find_path_atoms(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path, ly_bool output,
+        struct ly_set **set);
+
+/**
+ * @brief Get a schema node based on the given data path (JSON format, see @ref howtoXPath).
+ *
+ * @param[in] ctx libyang context, set for absolute paths.
+ * @param[in] ctx_node Starting context node for a relative data path, set for relative paths.
+ * @param[in] path JSON path of the node to get.
+ * @param[in] output Search operation output instead of input.
+ * @return Found schema node or NULL.
+ */
+const struct lysc_node *lys_find_path(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path,
+        ly_bool output);
+
+/**
  * @brief Types of the different schema paths.
  */
 typedef enum {
diff --git a/tools/lint/commands.c b/tools/lint/commands.c
index 8c00587..51dd07c 100644
--- a/tools/lint/commands.c
+++ b/tools/lint/commands.c
@@ -503,7 +503,7 @@
     }
 
     if (target_path) {
-        const struct lysc_node *node = ly_ctx_get_node(ctx, NULL, target_path, 0);
+        const struct lysc_node *node = lys_find_path(ctx, NULL, target_path, 0);
         if (node) {
             ret = lys_print_node(out, node, format, tree_ll, output_opts);
         } else {
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index 70f700a..7d86baa 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -788,7 +788,7 @@
     /* convert (print) to FORMAT */
     if (outformat_s) {
         if (outtarget_s) {
-            const struct lysc_node *node = ly_ctx_get_node(ctx, NULL, outtarget_s, 0);
+            const struct lysc_node *node = lys_find_path(ctx, NULL, outtarget_s, 0);
             if (node) {
                 lys_print_node(out, node, outformat_s, outline_length_s, outoptions_s);
             } else {