schema CHANGE remove LYEXT_PARENT duplicating ly_stmt

Removing the enumeration also leads to simplify the extension instance
structure where was the information about the parent structure duplicated.
diff --git a/src/parser_stmt.c b/src/parser_stmt.c
index 4c21d74..d15cf5d 100644
--- a/src/parser_stmt.c
+++ b/src/parser_stmt.c
@@ -95,8 +95,8 @@
 
     /* store name and insubstmt info */
     LY_CHECK_RET(lydict_insert(PARSER_CTX(ctx), stmt->stmt, 0, &e->name));
-    e->insubstmt = insubstmt;
-    e->insubstmt_index = insubstmt_index;
+    e->parent_stmt = insubstmt;
+    e->parent_stmt_index = insubstmt_index;
     /* TODO (duplicate) e->child = stmt->child; */
 
     /* get optional argument */
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 9649002..a3b5c03 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -862,8 +862,8 @@
     /* store the rest of information */
     e->format = LY_PREF_SCHEMA;
     e->prefix_data = ctx->parsed_mod;
-    e->insubstmt = insubstmt;
-    e->insubstmt_index = insubstmt_index;
+    e->parent_stmt = insubstmt;
+    e->parent_stmt_index = insubstmt_index;
 
     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {
         LY_CHECK_RET(parse_ext_substmt(ctx, kw, word, word_len, &e->child));
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 24ed410..5c9ae31 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -3172,8 +3172,8 @@
     LY_CHECK_RET(ly_store_prefix_data(ctx->xmlctx->ctx, e->name, strlen(e->name), LY_PREF_XML, &ctx->xmlctx->ns,
             &e->format, &e->prefix_data));
 
-    e->insubstmt = subelem;
-    e->insubstmt_index = subelem_index;
+    e->parent_stmt = subelem;
+    e->parent_stmt_index = subelem_index;
 
     LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
 
diff --git a/src/plugins_exts.c b/src/plugins_exts.c
index 17333b8..9148661 100644
--- a/src/plugins_exts.c
+++ b/src/plugins_exts.c
@@ -51,59 +51,3 @@
 
     return NULL;
 }
-
-API const char *
-lyext_parent2str(LYEXT_PARENT type)
-{
-    switch (type) {
-    case LYEXT_PAR_MODULE:
-        return "module";
-    case LYEXT_PAR_NODE:
-        return "data node";
-    case LYEXT_PAR_INPUT:
-        return "input";
-    case LYEXT_PAR_OUTPUT:
-        return "output";
-    case LYEXT_PAR_TYPE:
-        return "type";
-    case LYEXT_PAR_TYPE_BIT:
-        return "bit";
-    case LYEXT_PAR_TYPE_ENUM:
-        return "enum";
-    case LYEXT_PAR_MUST:
-        return "must";
-    case LYEXT_PAR_PATTERN:
-        return "pattern";
-    case LYEXT_PAR_LENGTH:
-        return "length";
-    case LYEXT_PAR_RANGE:
-        return "range";
-    case LYEXT_PAR_WHEN:
-        return "when";
-    case LYEXT_PAR_IDENT:
-        return "identity";
-    case LYEXT_PAR_EXT:
-        return "extension instance";
-    case LYEXT_PAR_IMPORT:
-        return "import";
-    /* YANG allows extension instances inside the following statements,
-     * but they do not have any meaning in current libyang
-        case LYEXT_PAR_TPDF:
-            return "typedef";
-        case LYEXT_PAR_EXTINST:
-            return "extension";
-        case LYEXT_PAR_REFINE:
-            return "refine";
-        case LYEXT_PAR_DEVIATION:
-            return "deviation";
-        case LYEXT_PAR_DEVIATE:
-            return "deviate";
-        case LYEXT_PAR_INCLUDE:
-            return "include";
-        case LYEXT_PAR_REVISION:
-            return "revision";
-     */
-    default:
-        return "unknown";
-    }
-}
diff --git a/src/plugins_exts_metadata.c b/src/plugins_exts_metadata.c
index 961a85e..43cb48d 100644
--- a/src/plugins_exts_metadata.c
+++ b/src/plugins_exts_metadata.c
@@ -52,9 +52,9 @@
     LY_ARRAY_COUNT_TYPE u;
 
     /* annotations can appear only at the top level of a YANG module or submodule */
-    if (c_ext->parent_type != LYEXT_PAR_MODULE) {
+    if ((c_ext->parent_stmt != LY_STMT_MODULE) && (c_ext->parent_stmt != LY_STMT_SUBMODULE)) {
         lyext_log(c_ext, LY_LLERR, LY_EVALID, cctx->path, "Extension %s is allowed only at the top level of a YANG module or submodule, but it is placed in \"%s\" statement.",
-                p_ext->name, lyext_parent2str(c_ext->parent_type));
+                p_ext->name, ly_stmt2str(c_ext->parent_stmt));
         return LY_EVALID;
     }
     /* check mandatory argument */
diff --git a/src/plugins_exts_nacm.c b/src/plugins_exts_nacm.c
index 460ca75..7674002 100644
--- a/src/plugins_exts_nacm.c
+++ b/src/plugins_exts_nacm.c
@@ -55,7 +55,7 @@
 
         inherited->def = lysc_ext_dup(arg->c_ext->def);
         inherited->parent = node;
-        inherited->parent_type = LYEXT_PAR_NODE;
+        inherited->parent_stmt = lys_nodetype2stmt(node->nodetype);
         if (arg->c_ext->argument) {
             LY_CHECK_RET(lydict_insert(node->module->ctx, arg->c_ext->argument, strlen(arg->c_ext->argument),
                     &inherited->argument));
@@ -92,9 +92,9 @@
     }
 
     /* check that the extension is instantiated at an allowed place - data node */
-    if (c_ext->parent_type != LYEXT_PAR_NODE) {
+    if (!LY_STMT_IS_NODE(c_ext->parent_stmt)) {
         lyext_log(c_ext, LY_LLWRN, 0, cctx->path, "Extension %s is allowed only in a data nodes, but it is placed in \"%s\" statement.",
-                p_ext->name, lyext_parent2str(c_ext->parent_type));
+                p_ext->name, ly_stmt2str(c_ext->parent_stmt));
         return LY_ENOT;
     } else {
         parent = (struct lysc_node *)c_ext->parent;
diff --git a/src/plugins_exts_yangdata.c b/src/plugins_exts_yangdata.c
index 4978f35..75c4e57 100644
--- a/src/plugins_exts_yangdata.c
+++ b/src/plugins_exts_yangdata.c
@@ -52,10 +52,10 @@
     uint32_t prev_options = cctx->options;
 
     /* yang-data can appear only at the top level of a YANG module or submodule */
-    if (c_ext->parent_type != LYEXT_PAR_MODULE) {
+    if ((c_ext->parent_stmt != LY_STMT_MODULE) && (c_ext->parent_stmt != LY_STMT_SUBMODULE)) {
         lyext_log(c_ext, LY_LLWRN, 0, cctx->path,
                 "Extension %s is ignored since it appears as a non top-level statement in \"%s\" statement.",
-                p_ext->name, lyext_parent2str(c_ext->parent_type));
+                p_ext->name, ly_stmt2str(c_ext->parent_stmt));
         return LY_ENOT;
     }
     /* check mandatory argument */
diff --git a/src/printer_yang.c b/src/printer_yang.c
index bf1c8a6..fbaa2e6 100644
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -220,7 +220,7 @@
         }
 
         count--;
-        if ((ext->flags & LYS_INTERNAL) || (ext->insubstmt != substmt) || (ext->insubstmt_index != substmt_index)) {
+        if ((ext->flags & LYS_INTERNAL) || (ext->parent_stmt != substmt) || (ext->parent_stmt_index != substmt_index)) {
             continue;
         }
 
@@ -283,7 +283,7 @@
 
     LEVEL++;
     LY_ARRAY_FOR(ext, u) {
-        if ((((struct lysp_ext_instance *)ext)[u].insubstmt != substmt) || (((struct lysp_ext_instance *)ext)[u].insubstmt_index != substmt_index)) {
+        if ((((struct lysp_ext_instance *)ext)[u].parent_stmt != substmt) || (((struct lysp_ext_instance *)ext)[u].parent_stmt_index != substmt_index)) {
             continue;
         }
         if (ctx->schema == LYS_YPR_PARSED) {
@@ -2301,7 +2301,7 @@
         }
 
         count--;
-        if ((ext->insubstmt != substmt) || (ext->insubstmt_index != substmt_index)) {
+        if ((ext->parent_stmt != substmt) || (ext->parent_stmt_index != substmt_index)) {
             continue;
         }
 
diff --git a/src/printer_yin.c b/src/printer_yin.c
index 1531f65..e1154d0 100644
--- a/src/printer_yin.c
+++ b/src/printer_yin.c
@@ -109,7 +109,7 @@
 
     LEVEL++;
     LY_ARRAY_FOR(ext, u) {
-        if ((((struct lysp_ext_instance *)ext)[u].insubstmt != substmt) || (((struct lysp_ext_instance *)ext)[u].insubstmt_index != substmt_index)) {
+        if ((((struct lysp_ext_instance *)ext)[u].parent_stmt != substmt) || (((struct lysp_ext_instance *)ext)[u].parent_stmt_index != substmt_index)) {
             continue;
         }
         yprp_extension_instances(ctx, substmt, substmt_index, &((struct lysp_ext_instance *)ext)[u], &extflag, 1);
@@ -1261,7 +1261,7 @@
         }
 
         count--;
-        if ((ext->flags & LYS_INTERNAL) || (ext->insubstmt != substmt) || (ext->insubstmt_index != substmt_index)) {
+        if ((ext->flags & LYS_INTERNAL) || (ext->parent_stmt != substmt) || (ext->parent_stmt_index != substmt_index)) {
             continue;
         }
 
diff --git a/src/schema_compile.c b/src/schema_compile.c
index b2a9a9e..3e50e1e 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -62,7 +62,7 @@
         DUP_STRING_GOTO(ctx->ctx, ext_p->name, ext_p->compiled->name, ret, done);
         DUP_STRING_GOTO(ctx->ctx, ext_p->argument, ext_p->compiled->argument, ret, done);
         ext_p->compiled->module = (struct lys_module *)ext_mod;
-        COMPILE_EXTS_GOTO(ctx, ext_p->exts, ext_p->compiled->exts, *ext, LYEXT_PAR_EXT, ret, done);
+        COMPILE_EXTS_GOTO(ctx, ext_p->exts, ext_p->compiled->exts, *ext, ret, done);
 
         lysc_update_path(ctx, NULL, NULL);
         lysc_update_path(ctx, NULL, NULL);
@@ -83,7 +83,7 @@
 
 LY_ERR
 lys_compile_ext(struct lysc_ctx *ctx, struct lysp_ext_instance *ext_p, struct lysc_ext_instance *ext, void *parent,
-        LYEXT_PARENT parent_type, const struct lys_module *ext_mod)
+        const struct lys_module *ext_mod)
 {
     LY_ERR r, ret = LY_SUCCESS;
     const char *tmp, *name, *prefix;
@@ -93,13 +93,12 @@
     DUP_STRING(ctx->ctx, ext_p->argument, ext->argument, ret);
     LY_CHECK_RET(ret);
 
-    ext->insubstmt = ext_p->insubstmt;
-    ext->insubstmt_index = ext_p->insubstmt_index;
+    ext->parent_stmt = ext_p->parent_stmt;
+    ext->parent_stmt_index = ext_p->parent_stmt_index;
     ext->module = ctx->cur_mod;
     ext->parent = parent;
-    ext->parent_type = parent_type;
 
-    lysc_update_path(ctx, ext->parent_type == LYEXT_PAR_NODE ? ((struct lysc_node *)ext->parent)->module : NULL, "{extension}");
+    lysc_update_path(ctx, LY_STMT_IS_NODE(ext->parent_stmt) ? ((struct lysc_node *)ext->parent)->module : NULL, "{extension}");
     lysc_update_path(ctx, NULL, ext_p->name);
 
     /* parse the prefix */
@@ -397,7 +396,7 @@
         DUP_STRING_GOTO(ctx_sc->ctx, identities_p[u].ref, ident->ref, ret, done);
         ident->module = ctx_sc->cur_mod;
         /* backlinks (derived) can be added no sooner than when all the identities in the current module are present */
-        COMPILE_EXTS_GOTO(ctx_sc, identities_p[u].exts, ident->exts, ident, LYEXT_PAR_IDENT, ret, done);
+        COMPILE_EXTS_GOTO(ctx_sc, identities_p[u].exts, ident->exts, ident, ret, done);
         ident->flags = identities_p[u].flags;
 
         lysc_update_path(ctx_sc, NULL, NULL);
@@ -1705,7 +1704,7 @@
     }
 
     /* extension instances */
-    COMPILE_EXTS_GOTO(&ctx, sp->exts, mod_c->exts, mod_c, LYEXT_PAR_MODULE, ret, error);
+    COMPILE_EXTS_GOTO(&ctx, sp->exts, mod_c->exts, mod_c, ret, error);
 
     /* the same for submodules */
     LY_ARRAY_FOR(sp->includes, u) {
@@ -1727,7 +1726,7 @@
             LY_CHECK_GOTO(ret, error);
         }
 
-        COMPILE_EXTS_GOTO(&ctx, submod->exts, mod_c->exts, mod_c, LYEXT_PAR_MODULE, ret, error);
+        COMPILE_EXTS_GOTO(&ctx, submod->exts, mod_c->exts, mod_c, ret, error);
     }
     ctx.pmod = sp;
 
diff --git a/src/schema_compile.h b/src/schema_compile.h
index 03935a1..c79d130 100644
--- a/src/schema_compile.h
+++ b/src/schema_compile.h
@@ -159,13 +159,13 @@
         } \
     }
 
-#define COMPILE_EXTS_GOTO(CTX, EXTS_P, EXT_C, PARENT, PARENT_TYPE, RET, GOTO) \
+#define COMPILE_EXTS_GOTO(CTX, EXTS_P, EXT_C, PARENT, RET, GOTO) \
     if (EXTS_P) { \
         LY_ARRAY_COUNT_TYPE __u = (EXT_C) ? LY_ARRAY_COUNT(EXT_C) : 0; \
         LY_ARRAY_CREATE_GOTO((CTX)->ctx, EXT_C, __u + LY_ARRAY_COUNT(EXTS_P), RET, GOTO); \
         LY_ARRAY_FOR(EXTS_P, __u) { \
             LY_ARRAY_INCREMENT(EXT_C); \
-            RET = lys_compile_ext(CTX, &(EXTS_P)[__u], &(EXT_C)[LY_ARRAY_COUNT(EXT_C) - 1], PARENT, PARENT_TYPE, NULL); \
+            RET = lys_compile_ext(CTX, &(EXTS_P)[__u], &(EXT_C)[LY_ARRAY_COUNT(EXT_C) - 1], PARENT, NULL); \
             if (RET == LY_ENOT) { \
                 LY_ARRAY_DECREMENT(EXT_C); \
                 RET = LY_SUCCESS; \
@@ -182,14 +182,13 @@
  * @param[in] ext_p Parsed extension instance.
  * @param[in,out] ext Prepared compiled extension instance.
  * @param[in] parent Extension instance parent.
- * @param[in] parent_type Extension instance parent type.
  * @param[in] ext_mod Optional module with the extension instance extension definition, set only for internal annotations.
  * @return LY_SUCCESS on success.
  * @return LY_ENOT if the extension is disabled and should be ignored.
  * @return LY_ERR on error.
  */
 LY_ERR lys_compile_ext(struct lysc_ctx *ctx, struct lysp_ext_instance *ext_p, struct lysc_ext_instance *ext, void *parent,
-        LYEXT_PARENT parent_type, const struct lys_module *ext_mod);
+        const struct lys_module *ext_mod);
 
 /**
  * @brief Compile information from the identity statement
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index b224376..7b1b5c0 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -241,7 +241,7 @@
     (*when)->context = (struct lysc_node *)ctx_node;
     DUP_STRING_GOTO(ctx->ctx, when_p->dsc, (*when)->dsc, ret, done);
     DUP_STRING_GOTO(ctx->ctx, when_p->ref, (*when)->ref, ret, done);
-    COMPILE_EXTS_GOTO(ctx, when_p->exts, (*when)->exts, (*when), LYEXT_PAR_WHEN, ret, done);
+    COMPILE_EXTS_GOTO(ctx, when_p->exts, (*when)->exts, (*when), ret, done);
     (*when)->flags = flags & LYS_STATUS_MASK;
 
 done:
@@ -302,7 +302,7 @@
     DUP_STRING_GOTO(ctx->ctx, must_p->emsg, must->emsg, ret, done);
     DUP_STRING_GOTO(ctx->ctx, must_p->dsc, must->dsc, ret, done);
     DUP_STRING_GOTO(ctx->ctx, must_p->ref, must->ref, ret, done);
-    COMPILE_EXTS_GOTO(ctx, must_p->exts, must->exts, must, LYEXT_PAR_MUST, ret, done);
+    COMPILE_EXTS_GOTO(ctx, must_p->exts, must->exts, must, ret, done);
 
 done:
     return ret;
@@ -1088,7 +1088,7 @@
         DUP_STRING_GOTO(ctx->ctx, patterns_p[u].emsg, (*pattern)->emsg, ret, done);
         DUP_STRING_GOTO(ctx->ctx, patterns_p[u].dsc, (*pattern)->dsc, ret, done);
         DUP_STRING_GOTO(ctx->ctx, patterns_p[u].ref, (*pattern)->ref, ret, done);
-        COMPILE_EXTS_GOTO(ctx, patterns_p[u].exts, (*pattern)->exts, (*pattern), LYEXT_PAR_PATTERN, ret, done);
+        COMPILE_EXTS_GOTO(ctx, patterns_p[u].exts, (*pattern)->exts, (*pattern), ret, done);
     }
 done:
     return ret;
@@ -1280,8 +1280,7 @@
         } else {
             e->position = cur_pos;
         }
-        COMPILE_EXTS_GOTO(ctx, enums_p[u].exts, e->exts, e, basetype == LY_TYPE_ENUM ? LYEXT_PAR_TYPE_ENUM :
-                LYEXT_PAR_TYPE_BIT, ret, done);
+        COMPILE_EXTS_GOTO(ctx, enums_p[u].exts, e->exts, e, ret, done);
 
         if (basetype == LY_TYPE_BITS) {
             /* keep bits ordered by position */
@@ -1403,7 +1402,7 @@
             LY_CHECK_RET(lys_compile_type_range(ctx, type_p->length, basetype, 1, 0,
                     base ? ((struct lysc_type_bin *)base)->length : NULL, &bin->length));
             if (!tpdfname) {
-                COMPILE_EXTS_GOTO(ctx, type_p->length->exts, bin->length->exts, bin->length, LYEXT_PAR_LENGTH, ret, cleanup);
+                COMPILE_EXTS_GOTO(ctx, type_p->length->exts, bin->length->exts, bin->length, ret, cleanup);
             }
         }
         break;
@@ -1461,7 +1460,7 @@
             LY_CHECK_RET(lys_compile_type_range(ctx, type_p->range, basetype, 0, dec->fraction_digits,
                     base ? ((struct lysc_type_dec *)base)->range : NULL, &dec->range));
             if (!tpdfname) {
-                COMPILE_EXTS_GOTO(ctx, type_p->range->exts, dec->range->exts, dec->range, LYEXT_PAR_RANGE, ret, cleanup);
+                COMPILE_EXTS_GOTO(ctx, type_p->range->exts, dec->range->exts, dec->range, ret, cleanup);
             }
         }
         break;
@@ -1473,7 +1472,7 @@
             LY_CHECK_RET(lys_compile_type_range(ctx, type_p->length, basetype, 1, 0,
                     base ? ((struct lysc_type_str *)base)->length : NULL, &str->length));
             if (!tpdfname) {
-                COMPILE_EXTS_GOTO(ctx, type_p->length->exts, str->length->exts, str->length, LYEXT_PAR_LENGTH, ret, cleanup);
+                COMPILE_EXTS_GOTO(ctx, type_p->length->exts, str->length->exts, str->length, ret, cleanup);
             }
         } else if (base && ((struct lysc_type_str *)base)->length) {
             str->length = lysc_range_dup(ctx->ctx, ((struct lysc_type_str *)base)->length);
@@ -1521,7 +1520,7 @@
             LY_CHECK_RET(lys_compile_type_range(ctx, type_p->range, basetype, 0, 0,
                     base ? ((struct lysc_type_num *)base)->range : NULL, &num->range));
             if (!tpdfname) {
-                COMPILE_EXTS_GOTO(ctx, type_p->range->exts, num->range->exts, num->range, LYEXT_PAR_RANGE, ret, cleanup);
+                COMPILE_EXTS_GOTO(ctx, type_p->range->exts, num->range->exts, num->range, ret, cleanup);
             }
         }
         break;
@@ -1920,7 +1919,7 @@
         ++(*type)->refcount;
     }
 
-    COMPILE_EXTS_GOTO(ctx, type_p->exts, (*type)->exts, (*type), LYEXT_PAR_TYPE, ret, cleanup);
+    COMPILE_EXTS_GOTO(ctx, type_p->exts, (*type)->exts, (*type), ret, cleanup);
 
 cleanup:
     ly_set_erase(&tpdf_chain, free);
@@ -2383,7 +2382,7 @@
     LY_CHECK_GOTO(ret = node_compile_spec(ctx, pnode, node), cleanup);
 
     /* final compilation tasks that require the node to be connected */
-    COMPILE_EXTS_GOTO(ctx, pnode->exts, node->exts, node, LYEXT_PAR_NODE, ret, cleanup);
+    COMPILE_EXTS_GOTO(ctx, pnode->exts, node->exts, node, ret, cleanup);
     if (node->flags & LYS_MAND_TRUE) {
         /* inherit LYS_MAND_TRUE in parent containers */
         lys_compile_mandatory_parents(parent, 1);
@@ -2425,8 +2424,7 @@
     struct lysc_node_action_inout *inout = (struct lysc_node_action_inout *)node;
 
     COMPILE_ARRAY_GOTO(ctx, inout_p->musts, inout->musts, lys_compile_must, ret, done);
-    COMPILE_EXTS_GOTO(ctx, inout_p->exts, inout->exts, inout, inout_p->nodetype == LYS_INPUT ? LYEXT_PAR_INPUT : LYEXT_PAR_OUTPUT,
-            ret, done);
+    COMPILE_EXTS_GOTO(ctx, inout_p->exts, inout->exts, inout, ret, done);
     ctx->options |= (inout_p->nodetype == LYS_INPUT) ? LYS_COMPILE_RPC_INPUT : LYS_COMPILE_RPC_OUTPUT;
 
     LY_LIST_FOR(inout_p->child, child_p) {
diff --git a/src/tree_schema.c b/src/tree_schema.c
index e58e26b..4918644 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -1005,8 +1005,8 @@
     ext_p->format = LY_PREF_SCHEMA;
     ext_p->prefix_data = mod;
     ext_p->flags = LYS_INTERNAL;
-    ext_p->insubstmt = LY_STMT_NONE;
-    ext_p->insubstmt_index = 0;
+    ext_p->parent_stmt = LY_STMT_MODULE;
+    ext_p->parent_stmt_index = 0;
 
     ext_p->child = stmt = calloc(1, sizeof *ext_p->child);
     LY_CHECK_ERR_RET(!stmt, LOGMEM(mod->mod->ctx), LY_EMEM);
@@ -1071,8 +1071,8 @@
     ext_p->format = LY_PREF_SCHEMA;
     ext_p->prefix_data = mod;
     ext_p->flags = LYS_INTERNAL;
-    ext_p->insubstmt = LY_STMT_NONE;
-    ext_p->insubstmt_index = 0;
+    ext_p->parent_stmt = LY_STMT_MODULE;
+    ext_p->parent_stmt_index = 0;
 
     ext_p->child = stmt = calloc(1, sizeof *ext_p->child);
     LY_CHECK_ERR_RET(!stmt, LOGMEM(mod->mod->ctx), LY_EMEM);
@@ -1122,8 +1122,8 @@
     ext_p->format = LY_PREF_SCHEMA;
     ext_p->prefix_data = mod;
     ext_p->flags = LYS_INTERNAL;
-    ext_p->insubstmt = LY_STMT_NONE;
-    ext_p->insubstmt_index = 0;
+    ext_p->parent_stmt = LY_STMT_MODULE;
+    ext_p->parent_stmt_index = 0;
 
     ext_p->child = stmt = calloc(1, sizeof *ext_p->child);
     LY_CHECK_ERR_RET(!stmt, LOGMEM(mod->mod->ctx), LY_EMEM);
@@ -1173,8 +1173,8 @@
     ext_p->format = LY_PREF_SCHEMA;
     ext_p->prefix_data = mod;
     ext_p->flags = LYS_INTERNAL;
-    ext_p->insubstmt = LY_STMT_NONE;
-    ext_p->insubstmt_index = 0;
+    ext_p->parent_stmt = LY_STMT_MODULE;
+    ext_p->parent_stmt_index = 0;
 
     ext_p->child = stmt = calloc(1, sizeof *ext_p->child);
     LY_CHECK_ERR_RET(!stmt, LOGMEM(mod->mod->ctx), LY_EMEM);
diff --git a/src/tree_schema.h b/src/tree_schema.h
index 8a12ffa..cc90b5e 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -421,43 +421,6 @@
 };
 
 /**
- * @brief Extension instance structure parent enumeration
- */
-typedef enum {
-    LYEXT_PAR_MODULE,    /**< ::lysc_module */
-    LYEXT_PAR_NODE,      /**< ::lysc_node (and the derived structures including ::lysc_node_action and ::lysc_node_notif) */
-    LYEXT_PAR_INPUT,     /**< ::lysc_node_action_inout */
-    LYEXT_PAR_OUTPUT,    /**< ::lysc_node_action_inout */
-    LYEXT_PAR_TYPE,      /**< ::lysc_type */
-    LYEXT_PAR_TYPE_BIT,  /**< ::lysc_type_bitenum_item */
-    LYEXT_PAR_TYPE_ENUM, /**< ::lysc_type_bitenum_item */
-    LYEXT_PAR_MUST,      /**< ::lysc_must */
-    LYEXT_PAR_PATTERN,   /**< ::lysc_pattern */
-    LYEXT_PAR_LENGTH,    /**< ::lysc_range */
-    LYEXT_PAR_RANGE,     /**< ::lysc_range */
-    LYEXT_PAR_WHEN,      /**< ::lysc_when */
-    LYEXT_PAR_IDENT,     /**< ::lysc_ident */
-    LYEXT_PAR_EXT,       /**< ::lysc_ext */
-    LYEXT_PAR_IMPORT     /**< ::lysp_import */
-#if 0
-    LYEXT_PAR_TPDF,      /**< ::lysp_tpdf */
-    LYEXT_PAR_EXTINST,   /**< ::lysp_ext_instance */
-    LYEXT_PAR_REFINE,    /**< ::lysp_refine */
-    LYEXT_PAR_DEVIATION, /**< ::lysp_deviation */
-    LYEXT_PAR_DEVIATE,   /**< ::lysp_deviate */
-    LYEXT_PAR_INCLUDE,   /**< ::lysp_include */
-    LYEXT_PAR_REVISION   /**< ::lysp_revision */
-#endif
-} LYEXT_PARENT;
-
-/**
- * @brief Stringify extension instance parent type.
- * @param[in] type Parent type to stringify.
- * @return Constant string with the name of the parent statement.
- */
-const char *lyext_parent2str(LYEXT_PARENT type);
-
-/**
  * @brief Stringify statement identifier.
  * @param[in] stmt The statement identifier to stringify.
  * @return Constant string representation of the given @p stmt.
@@ -544,15 +507,14 @@
                                                  (see ::ly_type_store_resolve_prefix()) */
 
     void *parent;                           /**< pointer to the parent element holding the extension instance(s), use
-                                                 ::lysp_ext_instance#parent_type to access the schema element */
+                                                 ::lysp_ext_instance#parent_stmt to access the schema element */
     struct lysp_stmt *child;                /**< list of the extension's substatements (linked list) */
     struct lysc_ext_instance *compiled;     /**< pointer to the compiled data if any - in case the source format is YIN,
                                                  some of the information (argument) are available only after compilation */
-    enum ly_stmt insubstmt;                 /**< value identifying placement of the extension instance */
-    LY_ARRAY_COUNT_TYPE insubstmt_index;    /**< in case the instance is in a substatement, this identifies
-                                                 the index of that substatement */
+    enum ly_stmt parent_stmt;               /**< value identifying placement of the extension instance */
+    LY_ARRAY_COUNT_TYPE parent_stmt_index;  /**< in case the instance is in a substatement, this identifies
+                                                 the index of that substatement in its [sized array](@ref sizedarrays) (if any) */
     uint16_t flags;                         /**< LYS_INTERNAL value (@ref snodeflags) */
-    LYEXT_PARENT parent_type;               /**< type of the parent structure */
 };
 
 /**
@@ -1421,19 +1383,18 @@
  * @brief YANG extension instance
  */
 struct lysc_ext_instance {
-    uint32_t insubstmt_index;        /**< in case the instance is in a substatement that can appear multiple times,
-                                          this identifies the index of the substatement for this extension instance */
-    struct lys_module *module;       /**< module where the extension instantiated is defined */
     struct lysc_ext *def;            /**< pointer to the extension definition */
-    void *parent;                    /**< pointer to the parent element holding the extension instance(s), use
-                                          ::lysc_ext_instance#parent_type to access the schema element */
     const char *argument;            /**< optional value of the extension's argument */
-    enum ly_stmt insubstmt;          /**< value identifying placement of the extension instance in specific statement */
-    LYEXT_PARENT parent_type;        /**< type of the parent structure */
+    struct lys_module *module;       /**< module where the extension instantiated is defined */
     struct lysc_ext_instance *exts;  /**< list of the extension instances ([sized array](@ref sizedarrays)) */
-
     struct lysc_ext_substmt *substmts; /**< list of allowed substatements with the storage to access the present substatements */
     void *data;                      /**< private plugins's data, not used by libyang */
+
+    void *parent;                    /**< pointer to the parent element holding the extension instance(s), use
+                                          ::lysc_ext_instance#parent_stmt to access the schema element */
+    enum ly_stmt parent_stmt;        /**< value identifying placement of the extension instance in specific statement */
+    LY_ARRAY_COUNT_TYPE parent_stmt_index; /**< in case the instance is in a substatement, this identifies
+                                          the index of that substatement in its [sized array](@ref sizedarrays) (if any) */
 };
 
 /**
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index ab5b0d0..99f97e4 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -1824,7 +1824,7 @@
     LY_CHECK_ARG_RET(NULL, ext, LY_EINVAL);
 
     for ( ; index < LY_ARRAY_COUNT(ext); index++) {
-        if (ext[index].insubstmt == substmt) {
+        if (ext[index].parent_stmt == substmt) {
             return index;
         }
     }
diff --git a/tests/utests/extensions/test_yangdata.c b/tests/utests/extensions/test_yangdata.c
index 9829e36..02b50f1 100644
--- a/tests/utests/extensions/test_yangdata.c
+++ b/tests/utests/extensions/test_yangdata.c
@@ -118,7 +118,7 @@
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, &mod));
     assert_null(mod->compiled->exts);
     CHECK_LOG_CTX("Extension plugin \"libyang 2 - yang-data, version 1\": "
-            "Extension rc:yang-data is ignored since it appears as a non top-level statement in \"data node\" statement.",
+            "Extension rc:yang-data is ignored since it appears as a non top-level statement in \"container\" statement.",
             "/b:b/{extension='rc:yang-data'}/template");
     assert_int_equal(LY_SUCCESS, lys_print_mem(&printed, mod, LYS_OUT_YANG_COMPILED, 0));
     assert_string_equal(printed, info);
diff --git a/tests/utests/schema/test_parser_yang.c b/tests/utests/schema/test_parser_yang.c
index 7a904d5..0abb821 100644
--- a/tests/utests/schema/test_parser_yang.c
+++ b/tests/utests/schema/test_parser_yang.c
@@ -784,7 +784,7 @@
     /* extensions */
     TEST_GENERIC("prefix:test;}", mod->exts,
             assert_string_equal("prefix:test", mod->exts[0].name);
-            assert_int_equal(LY_STMT_MODULE, mod->exts[0].insubstmt));
+            assert_int_equal(LY_STMT_MODULE, mod->exts[0].parent_stmt));
     mod = mod_renew(YCTX);
 
     /* invalid substatement */
diff --git a/tests/utests/schema/test_parser_yin.c b/tests/utests/schema/test_parser_yin.c
index 0e1b09c..14f6b7d 100644
--- a/tests/utests/schema/test_parser_yin.c
+++ b/tests/utests/schema/test_parser_yin.c
@@ -121,7 +121,7 @@
 #define ELEMENT_WRAPPER_END "</status>"
 
 #define TEST_1_CHECK_LYSP_EXT_INSTANCE(NODE, INSUBSTMT)\
-    CHECK_LYSP_EXT_INSTANCE((NODE), NULL, 1, NULL, INSUBSTMT, 0, "myext:c-define", 0, 0, LY_PREF_XML)
+    CHECK_LYSP_EXT_INSTANCE((NODE), NULL, 1, NULL, INSUBSTMT, 0, "myext:c-define", LY_PREF_XML)
 
 struct lys_yin_parser_ctx *YCTX;
 
@@ -335,8 +335,7 @@
 
     ret = yin_parse_extension_instance(YCTX, LY_STMT_CONTACT, 0, &exts);
     assert_int_equal(ret, LY_SUCCESS);
-    CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL,
-            LY_STMT_CONTACT, 0, "myext:ext", 0, 0, LY_PREF_XML);
+    CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL, LY_STMT_CONTACT, 0, "myext:ext", LY_PREF_XML);
 
     CHECK_LYSP_STMT(exts->child, arg, 0, LYS_YIN_ATTR, 0, 1, stmt);
     stmt = "value";
@@ -356,8 +355,7 @@
 
     ret = yin_parse_extension_instance(YCTX, LY_STMT_CONTACT, 0, &exts);
     assert_int_equal(ret, LY_SUCCESS);
-    CHECK_LYSP_EXT_INSTANCE(exts, NULL, 0, NULL,
-            LY_STMT_CONTACT, 0, "myext:extension-elem", 0, 0, LY_PREF_XML);
+    CHECK_LYSP_EXT_INSTANCE(exts, NULL, 0, NULL, LY_STMT_CONTACT, 0, "myext:extension-elem", LY_PREF_XML);
     lysp_ext_instance_free(UTEST_LYCTX, exts);
     LY_ARRAY_FREE(exts);
     exts = NULL;
@@ -379,8 +377,7 @@
     ret = yin_parse_extension_instance(YCTX, LY_STMT_CONTACT, 0, &exts);
     assert_int_equal(ret, LY_SUCCESS);
 
-    CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL,
-            LY_STMT_CONTACT, 0, "myext:ext", 0, 0, LY_PREF_XML);
+    CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL, LY_STMT_CONTACT, 0, "myext:ext", LY_PREF_XML);
 
     stmt = "attr1";
     arg = "text1";
@@ -547,8 +544,7 @@
     const char *exts_name = "myext:custom";
     const char *exts_arg = "totally amazing extension";
 
-    CHECK_LYSP_EXT_INSTANCE(exts, exts_arg, 0, NULL,
-            LY_STMT_PREFIX, 0, exts_name, 0, 0, LY_PREF_XML);
+    CHECK_LYSP_EXT_INSTANCE(exts, exts_arg, 0, NULL, LY_STMT_PREFIX, 0, exts_name, LY_PREF_XML);
     assert_string_equal(value, "wsefsdf");
     assert_string_equal(units, "radians");
     assert_string_equal(when_p->cond, "condition...");
diff --git a/tests/utests/utests.h b/tests/utests/utests.h
index 09da1c5..b57df7b 100644
--- a/tests/utests/utests.h
+++ b/tests/utests/utests.h
@@ -428,27 +428,19 @@
  * @param[in] ARGUMENT  expected optional value of the extension's argument
  * @param[in] CHILD     0 -> node doesnt have child, 1 -> node have children
  * @param[in] COMPILED  0 -> compiled data dosnt exists, 1 -> compiled data exists
- * @param[in] INSUBSTMS expected value identifying placement of the extension instance
- * @param[in] INSUBSTMS_INDEX expected indentifi index
- * @param[in] PARENT    0-> check if node is root, 1-> check if node is not root
- * @param[in] PARENT_TYPE expected parent type ::LYEXT_PARENT. not relevat if PARENT == 0
+ * @param[in] PARENT_STMT expected value identifying placement of the extension instance
+ * @param[in] PARENT_STMT_INDEX expected indentifi index
  * @param[in] FORMAT    expected format
  */
-#define CHECK_LYSP_EXT_INSTANCE(NODE, ARGUMENT, CHILD, COMPILED, INSUBSTMT, INSUBSTMT_INDEX, NAME, HAS_PARENT, PARENT_TYPE, FORMAT) \
+#define CHECK_LYSP_EXT_INSTANCE(NODE, ARGUMENT, CHILD, COMPILED, PARENT_STMT, PARENT_STMT_INDEX, NAME, FORMAT) \
     assert_non_null(NODE); \
     CHECK_STRING((NODE)->argument, ARGUMENT); \
     CHECK_POINTER((NODE)->child, CHILD); \
     CHECK_POINTER((NODE)->compiled, COMPILED); \
     /*assert_int_equal((NODE)->flags, LYS_INTERNAL);*/ \
-    assert_int_equal((NODE)->insubstmt, INSUBSTMT); \
-    assert_int_equal((NODE)->insubstmt_index, INSUBSTMT_INDEX); \
+    assert_int_equal((NODE)->parent_stmt, PARENT_STMT); \
+    assert_int_equal((NODE)->parent_stmt_index, PARENT_STMT_INDEX); \
     assert_string_equal((NODE)->name, NAME); \
-    if (HAS_PARENT) { \
-        assert_non_null((NODE)->parent); \
-        assert_int_equal((NODE)->parent_type, PARENT_TYPE); \
-    } else { \
-        assert_null((NODE)->parent); \
-    } \
     assert_int_equal((NODE)->format, FORMAT);
 
 /**