data tree REFACTOR remove support for NETCONF op encoding

... for now. Support only our own representation.
diff --git a/src/in.c b/src/in.c
index 279c54d..26f4226 100644
--- a/src/in.c
+++ b/src/in.c
@@ -386,7 +386,7 @@
     }
 
     if (snode->nodetype & (LYS_RPC | LYS_ACTION)) {
-        if (lydctx->int_opts & LYD_INTOPT_RPC) {
+        if (lydctx->int_opts & (LYD_INTOPT_RPC | LYD_INTOPT_REPLY)) {
             if (lydctx->op_node) {
                 LOGVAL(lydctx->data_ctx->ctx, LY_VLOG_LYSC, snode, LYVE_DATA, "Unexpected %s element \"%s\", %s \"%s\" already parsed.",
                         lys_nodetype2str(snode->nodetype), snode->name,
diff --git a/src/parser_data.h b/src/parser_data.h
index 02175d4..730b3b7 100644
--- a/src/parser_data.h
+++ b/src/parser_data.h
@@ -276,69 +276,47 @@
         uint32_t validate_options, struct lyd_node **tree);
 
 /**
- * @brief Parse (and validate) data from the input handler as a YANG RPC/action invocation.
+ * @brief Parse (no validation) data from the input handler as a YANG RPC/action request.
  *
- * In case o LYD_XML @p format, the \<rpc\> envelope element is accepted if present. It is [checked](https://tools.ietf.org/html/rfc6241#section-4.1), an opaq
- * data node (lyd_node_opaq) is created and all its XML attributes are parsed and inserted into the node. As a content of the envelope, an RPC data or
- * \<action\> envelope element is expected. The \<action\> envelope element is also [checked](https://tools.ietf.org/html/rfc7950#section-7.15.2) and parsed as
- * the \<rpc\> envelope. Inside the \<action\> envelope, only an action data are expected.
- *
- * Similarly, in the case of LYD_JSON @p format, the same envelopes in form of JSON objects are accepted. Nothing
- * corresponding to the XML attributes is accepted in this case.
- *
- * @param[in] ctx Context to connect with the tree being built here.
- * @param[in] in The input handle to provide the dumped data in the specified @p format to parse (and validate).
+ * @param[in] ctx Context to connect with the tree being parsed.
+ * @param[in] in Input handle to provide the dumped data in the specified @p format to parse.
  * @param[in] format Format of the input data to be parsed.
- * @param[out] tree Resulting full RPC/action tree built from the input data. The returned data are expected to be freed using ::lyd_free_all().
+ * @param[out] tree Resulting full RPC/action request tree built from the input data. The returned data are expected to be freed using ::lyd_free_all().
  * In contrast to YANG data tree, result of parsing RPC/action cannot be NULL until an error occurs.
  * @param[out] op Optional pointer to the actual operation node inside the full action @p tree, useful only for action.
- * @return LY_SUCCESS in case of successful parsing (and validation).
+ * @return LY_SUCCESS in case of successful parsing.
  * @return LY_ERR value in case of error. Additional error information can be obtained from the context using ly_err* functions.
  */
 LY_ERR lyd_parse_rpc(const struct ly_ctx *ctx, struct ly_in *in, LYD_FORMAT format, struct lyd_node **tree,
         struct lyd_node **op);
 
 /**
- * @brief Parse (and validate) data from the input handler as a YANG RPC/action reply.
+ * @brief Parse (no validation) data from the input handler as a YANG RPC/action reply.
  *
- * In case o LYD_XML @p format, the \<rpc-reply\> envelope element is accepted if present. It is [checked](https://tools.ietf.org/html/rfc6241#section-4.2), an opaq
- * data node (lyd_node_opaq) is created and all its XML attributes are parsed and inserted into the node.
- *
- * Similarly, in the case of LYD_JSON @p format, the same envelopes in form of JSON objects are accepted. Nothing
- * corresponding to the XML attributes is processed in this case.
- *
- * The reply data are strictly expected to be related to the provided RPC/action @p request.
- *
- * @param[in] request The RPC/action tree (result of ::lyd_parse_rpc()) of the request for the reply being parsed.
- * @param[in] in The input handle to provide the dumped data in the specified @p format to parse (and validate).
+ * @param[in] ctx Context to connect with the tree being parsed.
+ * @param[in] in Input handle to provide the dumped data in the specified @p format to parse (and validate).
  * @param[in] format Format of the input data to be parsed.
  * @param[out] tree Resulting full RPC/action reply tree built from the input data. The returned data are expected to be freed using ::lyd_free_all().
- * The reply tree always includes duplicated operation node (and its parents) of the @p request, so in contrast to YANG data tree,
- * the result of parsing RPC/action reply cannot be NULL until an error occurs. At least one of the @p tree and @p op output variables must be provided.
+ * In contrast to YANG data tree, result of parsing RPC/action cannot be NULL until an error occurs.
+ * At least one of the @p tree and @p op output variables must be provided.
  * @param[out] op Pointer to the actual operation node inside the full action reply @p tree, useful only for action. At least one of the @p op
  * and @p tree output variables must be provided.
- * @return LY_SUCCESS in case of successful parsing (and validation).
+ * @return LY_SUCCESS in case of successful parsing.
  * @return LY_ERR value in case of error. Additional error information can be obtained from the request's context using ly_err* functions.
  */
-LY_ERR lyd_parse_reply(const struct lyd_node *request, struct ly_in *in, LYD_FORMAT format, struct lyd_node **tree,
+LY_ERR lyd_parse_reply(const struct ly_ctx *ctx, struct ly_in *in, LYD_FORMAT format, struct lyd_node **tree,
         struct lyd_node **op);
 
 /**
- * @brief Parse XML string as YANG notification.
+ * @brief Parse (no validation) data from the input handler as a YANG notification.
  *
- * In case o LYD_XML @p format, the \<notification\> envelope element in combination with the child \<eventTime\> element are accepted if present. They are
- * [checked](https://tools.ietf.org/html/rfc5277#page-25), opaq data nodes (lyd_node_opaq) are created and all their XML attributes are parsed and inserted into the nodes.
- *
- * Similarly, in the case of LYD_JSON @p format, the same envelopes in form of JSON objects are accepted. Nothing
- * corresponding to the XML attributes is accepted in this case.
- *
- * @param[in] ctx Context to connect with the tree being built here.
- * @param[in] in The input handle to provide the dumped data in the specified @p format to parse (and validate).
+ * @param[in] ctx Context to connect with the tree being parsed.
+ * @param[in] in Input handle to provide the dumped data in the specified @p format to parse (and validate).
  * @param[in] format Format of the input data to be parsed.
- * @param[out] tree Resulting full Notification tree built from the input data. The returned data are expected to be freed using ::lyd_free_all().
- * In contrast to YANG data tree, result of parsing Notification cannot be NULL until an error occurs.
- * @param[out] ntf Optional pointer to the actual notification node inside the full Notification @p tree, useful for nested notifications.
- * @return LY_SUCCESS in case of successful parsing (and validation).
+ * @param[out] tree Resulting full notification tree built from the input data. The returned data are expected to be freed using ::lyd_free_all().
+ * In contrast to YANG data tree, result of parsing notification cannot be NULL until an error occurs.
+ * @param[out] ntf Optional pointer to the actual notification node inside the full notification @p tree, useful for nested notifications.
+ * @return LY_SUCCESS in case of successful parsing.
  * @return LY_ERR value in case of error. Additional error information can be obtained from the context using ly_err* functions.
  */
 LY_ERR lyd_parse_notif(const struct ly_ctx *ctx, struct ly_in *in, LYD_FORMAT format, struct lyd_node **tree,
diff --git a/src/parser_internal.h b/src/parser_internal.h
index b2b4cc2..408433d 100644
--- a/src/parser_internal.h
+++ b/src/parser_internal.h
@@ -125,10 +125,6 @@
 /**
  * @brief Parse XML string as YANG RPC/action invocation.
  *
- * Optional \<rpc\> envelope element is accepted if present. It is [checked](https://tools.ietf.org/html/rfc6241#section-4.1) and all
- * its XML attributes are parsed. As a content of the envelope, an RPC data or \<action\> envelope element is expected. The \<action\> envelope element is
- * also [checked](https://tools.ietf.org/html/rfc7950#section-7.15.2) and then an action data is expected as a content of this envelope.
- *
  * @param[in] ctx libyang context.
  * @param[in] in Input structure.
  * @param[out] tree_p Parsed full RPC/action tree.
@@ -140,9 +136,6 @@
 /**
  * @brief Parse XML string as YANG notification.
  *
- * Optional \<notification\> envelope element, if present, is [checked](https://tools.ietf.org/html/rfc5277#page-25)
- * and parsed. Specifically, its namespace and the child \<eventTime\> element and its value.
- *
  * @param[in] ctx libyang context.
  * @param[in] in Input structure.
  * @param[out] tree_p Parsed full notification tree.
@@ -154,16 +147,13 @@
 /**
  * @brief Parse XML string as YANG RPC/action reply.
  *
- * Optional \<rpc-reply\> envelope element, if present, is [checked](https://tools.ietf.org/html/rfc6241#section-4.2)
- * and all its XML attributes parsed.
- *
- * @param[in] request Data tree of the RPC/action request.
+ * @param[in] ctx libyang context.
  * @param[in] in Input structure.
- * @param[out] tree_p Parsed full reply tree. It always includes duplicated operation and parents of the @p request.
+ * @param[out] tree_p Parsed full RPC/action reply tree.
  * @param[out] op_p Optional pointer to the reply operation. Useful mainly for action.
  * @return LY_ERR value.
  */
-LY_ERR lyd_parse_xml_reply(const struct lyd_node *request, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p);
+LY_ERR lyd_parse_xml_reply(const struct ly_ctx *ctx, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p);
 
 /**
  * @brief Parse JSON string as YANG data tree.
@@ -182,9 +172,6 @@
 /**
  * @brief Parse JSON string as YANG notification.
  *
- * Optional top-level "notification" envelope object, if present, is [checked](https://tools.ietf.org/html/rfc5277#page-25)
- * and parsed. Specifically the child "eventTime" member and its value.
- *
  * @param[in] ctx libyang context.
  * @param[in] in Input structure.
  * @param[out] tree_p Parsed full notification tree.
@@ -196,10 +183,6 @@
 /**
  * @brief Parse JSON string as YANG RPC/action invocation.
  *
- * Optional top-level "rpc" envelope object, if present is is [checked](https://tools.ietf.org/html/rfc6241#section-4.1) and the parser
- * goes inside for the content, which is an RPC data or "action" envelope objects. The "action" envelope object is
- * also [checked](https://tools.ietf.org/html/rfc7950#section-7.15.2) and then an action data is expected as a content of this envelope.
- *
  * @param[in] ctx libyang context.
  * @param[in] in Input structure.
  * @param[out] tree_p Parsed full RPC/action tree.
@@ -211,15 +194,13 @@
 /**
  * @brief Parse JSON string as YANG RPC/action reply.
  *
- * Optional "rpc-reply" envelope object, if present, is [checked](https://tools.ietf.org/html/rfc6241#section-4.2).
- *
- * @param[in] request Data tree of the RPC/action request.
+ * @param[in] ctx libyang context.
  * @param[in] in Input structure.
- * @param[out] tree_p Parsed full reply tree. It always includes duplicated operation and parents of the @p request.
+ * @param[out] tree_p Parsed full RPC/action reply tree.
  * @param[out] op_p Optional pointer to the reply operation. Useful mainly for action.
  * @return LY_ERR value.
  */
-LY_ERR lyd_parse_json_reply(const struct lyd_node *request, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p);
+LY_ERR lyd_parse_json_reply(const struct ly_ctx *ctx, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p);
 
 /**
  * @brief Parse binary data as YANG data tree.
@@ -260,13 +241,13 @@
 /**
  * @brief Parse binary data as YANG RPC/action reply.
  *
- * @param[in] request Data tree of the RPC/action request.
+ * @param[in] ctx libyang context.
  * @param[in] in Input structure.
- * @param[out] tree_p Parsed full reply tree. It always includes duplicated operation and parents of the @p request.
+ * @param[out] tree_p Parsed full RPC/action reply tree.
  * @param[out] op_p Optional pointer to the reply operation. Useful mainly for action.
  * @return LY_ERR value.
  */
-LY_ERR lyd_parse_lyb_reply(const struct lyd_node *request, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p);
+LY_ERR lyd_parse_lyb_reply(const struct ly_ctx *ctx, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p);
 
 /**
  * @brief Check that a data node representing the @p snode is suitable based on options.
diff --git a/src/parser_json.c b/src/parser_json.c
index 4f09f86..6c4dde4 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -182,8 +182,7 @@
  * @param[in] prefix_len Length of the @p prefix.
  * @param[in] name Requested node's name.
  * @param[in] name_len Length of the @p name.
- * @param[in] parent Parent of the node beeing processed, can be NULL in case of top-level. Also the opaq node with LYD_NODE_OPAQ_ISENVELOPE hint
- * is accepted for searching top-level nodes.
+ * @param[in] parent Parent of the node being processed, can be NULL in case of top-level.
  * @param[out] snode_p Pointer to the found schema node corresponding to the input parameters.
  * @return LY_SUCCES on success, note that even in this case the returned value of @p snode_p can be NULL, so the data are expected to be parsed as opaq.
  * @return LY_EVALID on failure, error message is logged
@@ -200,11 +199,7 @@
     *snode_p = NULL;
 
     /* get the element module */
-    if (prefix_len || (parent && !parent->schema && (((struct lyd_node_opaq *)parent)->hints & LYD_NODEHINT_ENVELOPE))) {
-        if (!prefix_len) {
-            /* opaq parent (envelope) - the second part of the condition */
-            lydjson_get_node_prefix((struct lyd_node *)parent, NULL, 0, &prefix, &prefix_len);
-        }
+    if (prefix_len) {
         mod = ly_ctx_get_module_implemented2(lydctx->jsonctx->ctx, prefix, prefix_len);
     } else if (parent) {
         if (parent->schema) {
@@ -225,11 +220,6 @@
         }
     }
 
-    if (parent && !parent->schema && (((struct lyd_node_opaq *)parent)->hints & LYD_NODEHINT_ENVELOPE)) {
-        /* ignore the envelope parent when searchinf for the schema node */
-        parent = NULL;
-    }
-
     /* get the schema node */
     if (mod && (!parent || parent->schema)) {
         *snode_p = lys_find_child(parent ? parent->schema : NULL, mod, name, name_len, 0, getnext_opts);
@@ -1389,6 +1379,7 @@
     return ret;
 }
 
+#if 0
 /**
  * @brief Parse optional JSON envelope around the Notification data, including the eventTime data.
  *
@@ -1469,13 +1460,13 @@
     }
     return ret;
 }
+#endif
 
 LY_ERR
 lyd_parse_json_notif(const struct ly_ctx *ctx, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **ntf_p)
 {
     LY_ERR ret = LY_SUCCESS;
     struct lyd_json_ctx *lydctx = NULL;
-    struct lyd_node *ntf_e = NULL;
     struct lyd_node *tree = NULL;
     enum LYJSON_PARSER_STATUS status;
 
@@ -1485,6 +1476,7 @@
 
     lydctx->int_opts = LYD_INTOPT_NOTIF;
 
+#if 0
     /* parse "notification" and "eventTime", if present */
     ret = lydjson_notif_envelope(lydctx->jsonctx, &ntf_e, &status);
     if (ret == LY_ENOT) {
@@ -1492,6 +1484,7 @@
     } else if (ret) {
         goto cleanup;
     }
+#endif
 
     assert(status == LYJSON_OBJECT);
 
@@ -1515,31 +1508,10 @@
         goto cleanup;
     }
 
-    if (ntf_e) {
-        /* finish notification envelope */
-        ret = lyjson_ctx_next(lydctx->jsonctx, &status);
-        LY_CHECK_GOTO(ret, cleanup);
-        if (status == LYJSON_END) {
-            LOGVAL(ctx, LY_VLOG_LINE, &lydctx->jsonctx->line, LY_VCODE_EOF);
-            ret = LY_EVALID;
-            goto cleanup;
-        } else if (status != LYJSON_OBJECT_CLOSED) {
-            LOGVAL(ctx, LY_VLOG_LINE, &lydctx->jsonctx->line, LYVE_SYNTAX, "Unexpected sibling member \"%.*s\" of \"notification\".",
-                    lydctx->jsonctx->value_len, lydctx->jsonctx->value);
-            ret = LY_EVALID;
-            goto cleanup;
-        }
-    }
-
     if (ntf_p) {
         *ntf_p = lydctx->op_node;
     }
     assert(tree);
-    if (ntf_e) {
-        /* connect to the notification */
-        lyd_insert_node(ntf_e, NULL, tree);
-        tree = ntf_e;
-    }
     if (tree_p) {
         *tree_p = tree;
     }
@@ -1551,11 +1523,11 @@
     lyd_json_ctx_free((struct lyd_ctx *)lydctx);
     if (ret) {
         lyd_free_all(tree);
-        lyd_free_tree(ntf_e);
     }
     return ret;
 }
 
+#if 0
 /**
  * @brief Parse optional JSON envelope around the processed content.
  *
@@ -1619,13 +1591,13 @@
     }
     return LY_SUCCESS;
 }
+#endif
 
 LY_ERR
 lyd_parse_json_rpc(const struct ly_ctx *ctx, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p)
 {
     LY_ERR ret = LY_SUCCESS;
     struct lyd_json_ctx *lydctx = NULL;
-    struct lyd_node *rpc_e = NULL, *act_e = NULL;
     struct lyd_node *tree = NULL;
     enum LYJSON_PARSER_STATUS status;
 
@@ -1635,6 +1607,7 @@
 
     lydctx->int_opts = LYD_INTOPT_RPC;
 
+#if 0
     /* process envelope(s), if present */
 
     /* process rpc */
@@ -1655,10 +1628,11 @@
     }
 
 parse_content:
+#endif
     assert(status == LYJSON_OBJECT);
 
     /* read subtree(s) */
-    ret = lydjson_subtree_r(lydctx, act_e ? (struct lyd_node_inner *)act_e : (struct lyd_node_inner *)rpc_e, &tree);
+    ret = lydjson_subtree_r(lydctx, NULL, &tree);
     LY_CHECK_GOTO(ret, cleanup);
 
     /* finish linking metadata */
@@ -1667,8 +1641,7 @@
 
     /* make sure we have parsed some operation */
     if (!lydctx->op_node) {
-        LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_DATA, "Missing the %s node.",
-                act_e ? "action" : (rpc_e ? "rpc" : "rpc/action"));
+        LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_DATA, "Missing the rpc/action node.");
         ret = LY_EVALID;
         goto cleanup;
     } else if (lydctx->jsonctx->in->current[0] && (lyjson_ctx_status(lydctx->jsonctx, 0) != LYJSON_OBJECT_CLOSED)) {
@@ -1678,41 +1651,12 @@
         goto cleanup;
     }
 
-    if (act_e) {
-        /* finish action envelope */
-        ret = lydjson_object_envelope_close(lydctx->jsonctx, "action", &status);
-        LY_CHECK_GOTO(ret, cleanup);
-        if (lydctx->op_node->schema->nodetype != LYS_ACTION) {
-            LOGVAL(ctx, LY_VLOG_LYD, lydctx->op_node, LYVE_DATA, "Unexpected %s element, an \"action\" expected.",
-                    lys_nodetype2str(lydctx->op_node->schema->nodetype));
-            ret = LY_EVALID;
-            goto cleanup;
-        }
-    }
-    if (rpc_e) {
-        /* finish rpc envelope */
-        ret = lydjson_object_envelope_close(lydctx->jsonctx, "rpc", &status);
-        LY_CHECK_GOTO(ret, cleanup);
-        if (!act_e && (lydctx->op_node->schema->nodetype != LYS_RPC)) {
-            LOGVAL(ctx, LY_VLOG_LYD, lydctx->op_node, LYVE_DATA, "Unexpected %s element, an \"rpc\" expected.",
-                    lys_nodetype2str(lydctx->op_node->schema->nodetype));
-            ret = LY_EVALID;
-            goto cleanup;
-        }
-    }
-
     if (op_p) {
         *op_p = lydctx->op_node;
     }
     assert(tree);
     if (tree_p) {
-        if (rpc_e) {
-            *tree_p = rpc_e;
-        } else if (act_e) {
-            *tree_p = act_e;
-        } else {
-            *tree_p = tree;
-        }
+        *tree_p = tree;
     }
 
 cleanup:
@@ -1722,42 +1666,25 @@
     lyd_json_ctx_free((struct lyd_ctx *)lydctx);
     if (ret) {
         lyd_free_all(tree);
-        lyd_free_tree(act_e);
-        lyd_free_tree(rpc_e);
     }
     return ret;
 }
 
 LY_ERR
-lyd_parse_json_reply(const struct lyd_node *request, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p)
+lyd_parse_json_reply(const struct ly_ctx *ctx, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p)
 {
     LY_ERR ret = LY_SUCCESS;
     struct lyd_json_ctx *lydctx = NULL;
-    struct lyd_node *rpcr_e = NULL, *tree, *req_op, *rep_op = NULL;
+    struct lyd_node *tree = NULL;
     enum LYJSON_PARSER_STATUS status;
 
     /* init */
-    ret = lyd_parse_json_init(LYD_CTX(request), in, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0, &lydctx, &status);
+    ret = lyd_parse_json_init(ctx, in, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0, &lydctx, &status);
     LY_CHECK_GOTO(ret || status == LYJSON_END || status == LYJSON_OBJECT_EMPTY, cleanup);
 
     lydctx->int_opts = LYD_INTOPT_REPLY;
 
-    /* find request OP */
-    LYD_TREE_DFS_BEGIN((struct lyd_node *)request, req_op) {
-        if (req_op->schema->nodetype & (LYS_RPC | LYS_ACTION)) {
-            break;
-        }
-        LYD_TREE_DFS_END(request, req_op);
-    }
-    if (!(req_op->schema->nodetype & (LYS_RPC | LYS_ACTION))) {
-        LOGERR(LYD_CTX(request), LY_EINVAL, "No RPC/action in the request found.");
-        ret = LY_EINVAL;
-        goto cleanup;
-    }
-
-    /* duplicate request OP with parents */
-    LY_CHECK_GOTO(ret = lyd_dup_single(req_op, NULL, LYD_DUP_WITH_PARENTS, &rep_op), cleanup);
-
+#if 0
     /* parse "rpc-reply", if any */
     ret = lydjson_object_envelope(lydctx->jsonctx, NULL, "ietf-netconf", "rpc-reply", &rpcr_e, &status);
     if (ret == LY_ENOT) {
@@ -1765,35 +1692,24 @@
     } else if (ret) {
         goto cleanup;
     }
+#endif
 
     assert(status == LYJSON_OBJECT);
 
     /* read subtree(s) */
     while (lydctx->jsonctx->in->current[0] && status != LYJSON_OBJECT_CLOSED) {
-        ret = lydjson_subtree_r(lydctx, (struct lyd_node_inner *)rep_op, lyd_node_children_p(rep_op));
+        ret = lydjson_subtree_r(lydctx, NULL, &tree);
         LY_CHECK_GOTO(ret, cleanup);
 
         status = lyjson_ctx_status(lydctx->jsonctx, 0);
     }
 
     /* finish linking metadata */
-    ret = lydjson_metadata_finish(lydctx, lyd_node_children_p(rep_op));
+    ret = lydjson_metadata_finish(lydctx, &tree);
     LY_CHECK_GOTO(ret, cleanup);
 
-    if (rpcr_e) {
-        /* finish rpc-reply envelope */
-        ret = lydjson_object_envelope_close(lydctx->jsonctx, "rpc-reply", &status);
-        LY_CHECK_GOTO(ret, cleanup);
-    }
-
     if (op_p) {
-        *op_p = rep_op;
-    }
-    for (tree = rep_op; tree->parent; tree = lyd_parent(tree)) {}
-    if (rpcr_e) {
-        /* connect to the operation */
-        lyd_insert_node(rpcr_e, NULL, tree);
-        tree = rpcr_e;
+        *op_p =  lydctx->op_node;
     }
     if (tree_p) {
         *tree_p = tree;
@@ -1805,8 +1721,7 @@
 
     lyd_json_ctx_free((struct lyd_ctx *)lydctx);
     if (ret) {
-        lyd_free_all(rep_op);
-        lyd_free_tree(rpcr_e);
+        lyd_free_all(tree);
     }
     return ret;
 }
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index 30878c5..8a54c6e 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -1052,7 +1052,7 @@
     /* read the last zero, parsing finished */
     ly_in_skip(lybctx->lybctx->in, 1);
 
-    if (data_type == LYD_INTOPT_RPC) {
+    if (data_type == (LYD_INTOPT_RPC | LYD_INTOPT_REPLY)) {
         /* make sure we have parsed some operation */
         if (!lybctx->op_node) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_DATA, "Missing the \"rpc\"/\"action\" node.");
@@ -1064,17 +1064,6 @@
             *op_p = lybctx->op_node;
         }
         assert(tree);
-    } else if (data_type == LYD_INTOPT_REPLY) {
-        struct lyd_node_inner *iter;
-
-        assert(parent);
-
-        if (op_p) {
-            *op_p = (struct lyd_node *)(*parent);
-        }
-        for (iter = *parent; iter->parent; iter = iter->parent) {}
-        tree = (struct lyd_node *)iter;
-        *parent = NULL;
 
     } else if (data_type == LYD_INTOPT_NOTIF) {
         /* make sure we have parsed some notification */
@@ -1127,33 +1116,9 @@
 }
 
 LY_ERR
-lyd_parse_lyb_reply(const struct lyd_node *request, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p)
+lyd_parse_lyb_reply(const struct ly_ctx *ctx, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p)
 {
-    LY_ERR ret;
-    struct lyd_node *req_op, *rep_op = NULL;
-    const struct ly_ctx *ctx = LYD_CTX(request);
-
-    /* find request OP */
-    LYD_TREE_DFS_BEGIN((struct lyd_node *)request, req_op) {
-        if (req_op->schema->nodetype & (LYS_RPC | LYS_ACTION)) {
-            break;
-        }
-        LYD_TREE_DFS_END(request, req_op);
-    }
-    if (!(req_op->schema->nodetype & (LYS_RPC | LYS_ACTION))) {
-        LOGERR(LYD_CTX(request), LY_EINVAL, "No RPC/action in the request found.");
-        return LY_EINVAL;
-    }
-
-    /* duplicate request OP with parents */
-    LY_CHECK_RET(lyd_dup_single(req_op, NULL, LYD_DUP_WITH_PARENTS, &rep_op));
-
-    ret = lyd_parse_lyb_(ctx, (struct lyd_node_inner **)&rep_op, in, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0,
-            LYD_INTOPT_REPLY, tree_p, op_p, NULL);
-
-    lyd_free_all(rep_op);
-
-    return ret;
+    return lyd_parse_lyb_(ctx, NULL, in, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0, LYD_INTOPT_REPLY, tree_p, op_p, NULL);
 }
 
 API int
diff --git a/src/parser_xml.c b/src/parser_xml.c
index bddd17f..cb4fb82 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -658,6 +658,7 @@
     return ret;
 }
 
+#if 0
 static LY_ERR
 lydxml_envelope(struct lyxml_ctx *xmlctx, const char *name, const char *uri, struct lyd_node **envp)
 {
@@ -717,13 +718,13 @@
     lyd_free_attr_siblings(xmlctx->ctx, attr);
     return ret;
 }
+#endif
 
 LY_ERR
 lyd_parse_xml_rpc(const struct ly_ctx *ctx, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p)
 {
     LY_ERR ret = LY_SUCCESS;
     struct lyd_xml_ctx lydctx = {0};
-    struct lyd_node *rpc_e = NULL, *act_e = NULL;
     struct lyd_node *tree = NULL;
 
     /* init */
@@ -731,6 +732,7 @@
     lydctx.parse_options = LYD_PARSE_ONLY | LYD_PARSE_STRICT;
     lydctx.int_opts = LYD_INTOPT_RPC;
 
+#if 0
     /* parse "rpc", if any */
     LY_CHECK_GOTO(ret = lydxml_envelope(lydctx.xmlctx, "rpc", "urn:ietf:params:xml:ns:netconf:base:1.0", &rpc_e), cleanup);
 
@@ -738,6 +740,7 @@
         /* parse "action", if any */
         LY_CHECK_GOTO(ret = lydxml_envelope(lydctx.xmlctx, "action", "urn:ietf:params:xml:ns:yang:1", &act_e), cleanup);
     }
+#endif
 
     /* parse the rest of data normally */
     LY_CHECK_GOTO(ret = lydxml_subtree_r(&lydctx, NULL, &tree), cleanup);
@@ -754,52 +757,10 @@
         goto cleanup;
     }
 
-    /* finish XML parsing and check operation type */
-    if (act_e) {
-        if (lydctx.xmlctx->status != LYXML_ELEM_CLOSE) {
-            assert(lydctx.xmlctx->status == LYXML_ELEMENT);
-            LOGVAL(ctx, LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX, "Unexpected sibling element \"%.*s\" of \"action\".",
-                    lydctx.xmlctx->name_len, lydctx.xmlctx->name);
-            ret = LY_EVALID;
-            goto cleanup;
-        } else if (lydctx.op_node->schema->nodetype != LYS_ACTION) {
-            LOGVAL(ctx, LY_VLOG_LYD, lydctx.op_node, LYVE_DATA, "Unexpected %s element, an \"action\" expected.",
-                    lys_nodetype2str(lydctx.op_node->schema->nodetype));
-            ret = LY_EVALID;
-            goto cleanup;
-        }
-        LY_CHECK_GOTO(ret = lyxml_ctx_next(lydctx.xmlctx), cleanup);
-    }
-    if (rpc_e) {
-        if (lydctx.xmlctx->status != LYXML_ELEM_CLOSE) {
-            assert(lydctx.xmlctx->status == LYXML_ELEMENT);
-            LOGVAL(ctx, LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX, "Unexpected sibling element \"%.*s\" of \"rpc\".",
-                    lydctx.xmlctx->name_len, lydctx.xmlctx->name);
-            ret = LY_EVALID;
-            goto cleanup;
-        } else if (!act_e && (lydctx.op_node->schema->nodetype != LYS_RPC)) {
-            LOGVAL(ctx, LY_VLOG_LYD, lydctx.op_node, LYVE_DATA, "Unexpected %s element, an \"rpc\" expected.",
-                    lys_nodetype2str(lydctx.op_node->schema->nodetype));
-            ret = LY_EVALID;
-            goto cleanup;
-        }
-        LY_CHECK_GOTO(ret = lyxml_ctx_next(lydctx.xmlctx), cleanup);
-    }
-
     if (op_p) {
         *op_p = lydctx.op_node;
     }
     assert(tree);
-    if (act_e) {
-        /* connect to the action */
-        lyd_insert_node(act_e, NULL, tree);
-        tree = act_e;
-    }
-    if (rpc_e) {
-        /* connect to the rpc */
-        lyd_insert_node(rpc_e, NULL, tree);
-        tree = rpc_e;
-    }
     if (tree_p) {
         *tree_p = tree;
     }
@@ -810,12 +771,11 @@
     lyxml_ctx_free(lydctx.xmlctx);
     if (ret) {
         lyd_free_all(tree);
-        lyd_free_tree(act_e);
-        lyd_free_tree(rpc_e);
     }
     return ret;
 }
 
+#if 0
 static LY_ERR
 lydxml_notif_envelope(struct lyxml_ctx *xmlctx, struct lyd_node **envp)
 {
@@ -905,13 +865,13 @@
     }
     return ret;
 }
+#endif
 
 LY_ERR
 lyd_parse_xml_notif(const struct ly_ctx *ctx, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **ntf_p)
 {
     LY_ERR ret = LY_SUCCESS;
     struct lyd_xml_ctx lydctx = {0};
-    struct lyd_node *ntf_e = NULL;
     struct lyd_node *tree = NULL;
 
     /* init */
@@ -919,8 +879,10 @@
     lydctx.parse_options = LYD_PARSE_ONLY | LYD_PARSE_STRICT;
     lydctx.int_opts = LYD_INTOPT_NOTIF;
 
+#if 0
     /* parse "notification" and "eventTime", if present */
     LY_CHECK_GOTO(ret = lydxml_notif_envelope(lydctx.xmlctx, &ntf_e), cleanup);
+#endif
 
     /* parse the rest of data normally */
     LY_CHECK_GOTO(ret = lydxml_subtree_r(&lydctx, NULL, &tree), cleanup);
@@ -937,26 +899,50 @@
         goto cleanup;
     }
 
-    /* finish XML parsing */
-    if (ntf_e) {
-        if (lydctx.xmlctx->status != LYXML_ELEM_CLOSE) {
-            assert(lydctx.xmlctx->status == LYXML_ELEMENT);
-            LOGVAL(ctx, LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX, "Unexpected sibling element \"%.*s\" of \"notification\".",
-                    lydctx.xmlctx->name_len, lydctx.xmlctx->name);
-            ret = LY_EVALID;
-            goto cleanup;
-        }
-        LY_CHECK_GOTO(ret = lyxml_ctx_next(lydctx.xmlctx), cleanup);
-    }
-
     if (ntf_p) {
         *ntf_p = lydctx.op_node;
     }
     assert(tree);
-    if (ntf_e) {
-        /* connect to the notification */
-        lyd_insert_node(ntf_e, NULL, tree);
-        tree = ntf_e;
+    if (tree_p) {
+        *tree_p = tree;
+    }
+
+cleanup:
+    /* we have used parse_only flag */
+    assert(!lydctx.node_types.count && !lydctx.meta_types.count && !lydctx.node_when.count);
+    lyxml_ctx_free(lydctx.xmlctx);
+    if (ret) {
+        lyd_free_all(tree);
+    }
+    return ret;
+}
+
+LY_ERR
+lyd_parse_xml_reply(const struct ly_ctx *ctx, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p)
+{
+    LY_ERR ret = LY_SUCCESS;
+    struct lyd_xml_ctx lydctx = {0};
+    struct lyd_node *tree = NULL;
+
+    /* init */
+    LY_CHECK_GOTO(ret = lyxml_ctx_new(ctx, in, &lydctx.xmlctx), cleanup);
+    lydctx.parse_options = LYD_PARSE_ONLY | LYD_PARSE_STRICT;
+    lydctx.int_opts = LYD_INTOPT_REPLY;
+
+#if 0
+    /* parse "rpc-reply", if any */
+    LY_CHECK_GOTO(ret = lydxml_envelope(lydctx.xmlctx, "rpc-reply", "urn:ietf:params:xml:ns:netconf:base:1.0", &rpcr_e),
+            cleanup);
+#endif
+
+    /* parse the rest of data normally but connect them to the duplicated operation */
+    while (lydctx.xmlctx->status == LYXML_ELEMENT) {
+        ret = lydxml_subtree_r(&lydctx, NULL, &tree);
+        LY_CHECK_GOTO(ret, cleanup);
+    }
+
+    if (op_p) {
+        *op_p =  lydctx.op_node;
     }
     if (tree_p) {
         *tree_p = tree;
@@ -968,81 +954,6 @@
     lyxml_ctx_free(lydctx.xmlctx);
     if (ret) {
         lyd_free_all(tree);
-        lyd_free_tree(ntf_e);
-    }
-    return ret;
-}
-
-LY_ERR
-lyd_parse_xml_reply(const struct lyd_node *request, struct ly_in *in, struct lyd_node **tree_p, struct lyd_node **op_p)
-{
-    LY_ERR ret = LY_SUCCESS;
-    struct lyd_xml_ctx lydctx = {0};
-    struct lyd_node *rpcr_e = NULL, *tree, *req_op, *rep_op = NULL;
-
-    /* init */
-    LY_CHECK_GOTO(ret = lyxml_ctx_new(LYD_CTX(request), in, &lydctx.xmlctx), cleanup);
-    lydctx.parse_options = LYD_PARSE_ONLY | LYD_PARSE_STRICT;
-    lydctx.int_opts = LYD_INTOPT_REPLY;
-
-    /* find request OP */
-    LYD_TREE_DFS_BEGIN((struct lyd_node *)request, req_op) {
-        if (req_op->schema->nodetype & (LYS_RPC | LYS_ACTION)) {
-            break;
-        }
-        LYD_TREE_DFS_END(request, req_op);
-    }
-    if (!(req_op->schema->nodetype & (LYS_RPC | LYS_ACTION))) {
-        LOGERR(LYD_CTX(request), LY_EINVAL, "No RPC/action in the request found.");
-        ret = LY_EINVAL;
-        goto cleanup;
-    }
-
-    /* duplicate request OP with parents */
-    LY_CHECK_GOTO(ret = lyd_dup_single(req_op, NULL, LYD_DUP_WITH_PARENTS, &rep_op), cleanup);
-
-    /* parse "rpc-reply", if any */
-    LY_CHECK_GOTO(ret = lydxml_envelope(lydctx.xmlctx, "rpc-reply", "urn:ietf:params:xml:ns:netconf:base:1.0", &rpcr_e),
-            cleanup);
-
-    /* parse the rest of data normally but connect them to the duplicated operation */
-    while (lydctx.xmlctx->status == LYXML_ELEMENT) {
-        ret = lydxml_subtree_r(&lydctx, (struct lyd_node_inner *)rep_op, lyd_node_children_p(rep_op));
-        LY_CHECK_GOTO(ret, cleanup);
-    }
-
-    /* finish XML parsing and check operation type */
-    if (rpcr_e) {
-        if (lydctx.xmlctx->status != LYXML_ELEM_CLOSE) {
-            assert(lydctx.xmlctx->status == LYXML_ELEMENT);
-            LOGVAL(LYD_CTX(request), LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX,
-                    "Unexpected sibling element \"%.*s\" of \"rpc-reply\".", lydctx.xmlctx->name_len, lydctx.xmlctx->name);
-            ret = LY_EVALID;
-            goto cleanup;
-        }
-        LY_CHECK_GOTO(ret = lyxml_ctx_next(lydctx.xmlctx), cleanup);
-    }
-
-    if (op_p) {
-        *op_p = rep_op;
-    }
-    for (tree = rep_op; tree->parent; tree = lyd_parent(tree)) {}
-    if (rpcr_e) {
-        /* connect to the operation */
-        lyd_insert_node(rpcr_e, NULL, tree);
-        tree = rpcr_e;
-    }
-    if (tree_p) {
-        *tree_p = tree;
-    }
-
-cleanup:
-    /* we have used parse_only flag */
-    assert(!lydctx.node_types.count && !lydctx.meta_types.count && !lydctx.node_when.count);
-    lyxml_ctx_free(lydctx.xmlctx);
-    if (ret) {
-        lyd_free_all(rep_op);
-        lyd_free_tree(rpcr_e);
     }
     return ret;
 }
diff --git a/src/tree_data.c b/src/tree_data.c
index db2b836..f6e10d4 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -451,14 +451,13 @@
 }
 
 API LY_ERR
-lyd_parse_reply(const struct lyd_node *request, struct ly_in *in, LYD_FORMAT format, struct lyd_node **tree,
+lyd_parse_reply(const struct ly_ctx *ctx, struct ly_in *in, LYD_FORMAT format, struct lyd_node **tree,
         struct lyd_node **op)
 {
-    LY_CHECK_ARG_RET(NULL, request, LY_EINVAL);
-    LY_CHECK_ARG_RET(LYD_CTX(request), in, tree || op, LY_EINVAL);
+    LY_CHECK_ARG_RET(ctx, ctx, in, tree || op, LY_EINVAL);
 
     format = lyd_parse_get_format(in, format);
-    LY_CHECK_ARG_RET(LYD_CTX(request), format, LY_EINVAL);
+    LY_CHECK_ARG_RET(ctx, format, LY_EINVAL);
 
     /* init */
     if (tree) {
@@ -473,16 +472,16 @@
 
     switch (format) {
     case LYD_XML:
-        return lyd_parse_xml_reply(request, in, tree, op);
+        return lyd_parse_xml_reply(ctx, in, tree, op);
     case LYD_JSON:
-        return lyd_parse_json_reply(request, in, tree, op);
+        return lyd_parse_json_reply(ctx, in, tree, op);
     case LYD_LYB:
-        return lyd_parse_lyb_reply(request, in, tree, op);
+        return lyd_parse_lyb_reply(ctx, in, tree, op);
     case LYD_UNKNOWN:
         break;
     }
 
-    LOGINT_RET(LYD_CTX(request));
+    LOGINT_RET(ctx);
 }
 
 API LY_ERR
diff --git a/src/tree_data.h b/src/tree_data.h
index b1034be..e5830c2 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -672,8 +672,6 @@
  */
 #define LYD_NODEHINT_LIST       0x0080 /**< node is allowed to be a list instance */
 #define LYD_NODEHINT_LEAFLIST   0x0100 /**< node is allowed to be a leaf-list instance */
-#define LYD_NODEHINT_ENVELOPE   0x8000 /**< only found in opaque node hints; node is a special protocol-dependent
-                                            RPC/Action/Notification envelope */
 /**
  * @} lydnodehints
  */