Refactor RPC input generation

Change-Id: I4fac9ffc939a7df41a6e3f3332199da0070edb9e
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index dfdb7f0..e9da2ca 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -306,22 +306,9 @@
 
 DatastoreAccess::Tree SysrepoAccess::execute(const std::string& path, const Tree& input)
 {
-    auto inputNode = m_schema->dataNodeFromPath(path);
-    for (const auto& [k, v] : input) {
-        inputNode->new_path(m_session->get_context(), k.c_str(), leafDataToString(v).c_str(), LYD_ANYDATA_CONSTSTRING, LYD_PATH_OPT_UPDATE);
-    }
-
-    Tree res;
+    auto inputNode = treeToRpcInput(m_session->get_context(), path, input);
     auto output = m_session->rpc_send(inputNode);
-    if (output) {
-        // The output is "some top-level node". If we actually want the output of our RPC/action we need to use
-        // find_path.  Also, our `path` is fully prefixed, but the output paths aren't. So we use outputNode->path() to
-        // get the unprefixed path.
-
-        auto outputNode = output->find_path(path.c_str())->data().front();
-        lyNodesToTree(res, {outputNode}, joinPaths(outputNode->path(), "/"));
-    }
-    return res;
+    return rpcOutputToTree(path, output);
 }
 
 void SysrepoAccess::copyConfig(const Datastore source, const Datastore destination)