yin parser BUGFIX insert new nodes earlier to be able to check identifiers duplicity

To be able to check duplicity of identifiers (e.g. typedef names), we
need to be able to move in the schema tree. To do so, the nodes beeing
parsed must be inserted into the tree earlier than they were.
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 76a2ed4..0a29e46 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -2889,6 +2889,7 @@
 
     LOGDBG("YIN: parsing %s statement \"%s\"", yin->name, retval->name);
 
+    /* insert the node into the schema tree */
     if (lys_node_addchild(parent, lys_main_module(module), retval)) {
         goto error;
     }
@@ -3013,6 +3014,7 @@
 
     LOGDBG("YIN: parsing %s statement \"%s\"", yin->name, retval->name);
 
+    /* insert the node into the schema tree */
     if (lys_node_addchild(parent, lys_main_module(module), retval)) {
         goto error;
     }
@@ -3185,6 +3187,7 @@
 
     LOGDBG("YIN: parsing %s statement \"%s\"", yin->name, retval->name);
 
+    /* insert the node into the schema tree */
     if (lys_node_addchild(parent, lys_main_module(module), retval)) {
         goto error;
     }
@@ -3405,6 +3408,11 @@
 
     LOGDBG("YIN: parsing %s statement \"%s\"", yin->name, retval->name);
 
+    /* insert the node into the schema tree */
+    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
+        goto error;
+    }
+
     /* process list's specific children */
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (!sub->ns || strcmp(sub->ns->value, LY_NSYIN)) {
@@ -3614,10 +3622,6 @@
         }
     }
 
-    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
-        goto error;
-    }
-
     /* last part - process data nodes */
     LY_TREE_FOR_SAFE(root.child, next, sub) {
         if (!strcmp(sub->name, "container")) {
@@ -3719,6 +3723,11 @@
 
     LOGDBG("YIN: parsing %s statement \"%s\"", yin->name, retval->name);
 
+    /* insert the node into the schema tree */
+    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
+        goto error;
+    }
+
     /* process container's specific children */
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (!sub->ns) {
@@ -3819,10 +3828,6 @@
         }
     }
 
-    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
-        goto error;
-    }
-
     /* last part - process data nodes */
     LY_TREE_FOR_SAFE(root.child, next, sub) {
         if (!strcmp(sub->name, "container")) {
@@ -3891,6 +3896,11 @@
 
     LOGDBG("YIN: parsing %s statement \"%s\"", yin->name, retval->name);
 
+    /* insert the node into the schema tree */
+    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
+        goto error;
+    }
+
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (!sub->ns || strcmp(sub->ns->value, LY_NSYIN)) {
             /* garbage */
@@ -3935,10 +3945,6 @@
         }
     }
 
-    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
-        goto error;
-    }
-
     /* last part - process data nodes */
     if (!root.child) {
         LOGWRN("Grouping \"%s\" without children.", retval->name);
@@ -4022,6 +4028,11 @@
 
     LOGDBG("YIN: parsing %s statement \"%s\"", yin->name, retval->name);
 
+    /* insert the node into the schema tree */
+    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
+        goto error;
+    }
+
     /* data statements */
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (!sub->ns || strcmp(sub->ns->value, LY_NSYIN)) {
@@ -4068,10 +4079,6 @@
         }
     }
 
-    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
-        goto error;
-    }
-
     /* last part - process data nodes */
     LY_TREE_FOR_SAFE(root.child, next, sub) {
         if (!strcmp(sub->name, "container")) {
@@ -4139,6 +4146,11 @@
 
     LOGDBG("YIN: parsing %s statement \"%s\"", yin->name, retval->name);
 
+    /* insert the node into the schema tree */
+    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
+        goto error;
+    }
+
     /* process rpc's specific children */
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (!sub->ns || strcmp(sub->ns->value, LY_NSYIN)) {
@@ -4202,10 +4214,6 @@
         }
     }
 
-    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
-        goto error;
-    }
-
     /* last part - process data nodes */
     LY_TREE_FOR_SAFE(root.child, next, sub) {
         if (!strcmp(sub->name, "container")) {
@@ -4274,6 +4282,11 @@
 
     LOGDBG("YIN: parsing %s statement \"%s\"", yin->name, retval->name);
 
+    /* insert the node into the schema tree */
+    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
+        goto error;
+    }
+
     /* process rpc's specific children */
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (!sub->ns || strcmp(sub->ns->value, LY_NSYIN)) {
@@ -4349,10 +4362,6 @@
         }
     }
 
-    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
-        goto error;
-    }
-
     /* last part - process data nodes */
     LY_TREE_FOR_SAFE(root.child, next, sub) {
         if (!strcmp(sub->name, "grouping")) {
@@ -4416,6 +4425,11 @@
 
     LOGDBG("YIN: parsing %s statement \"%s\"", yin->name, retval->name);
 
+    /* insert the node into the schema tree */
+    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
+        goto error;
+    }
+
     /* get other properties of uses */
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (!sub->ns || strcmp(sub->ns->value, LY_NSYIN)) {
@@ -4471,10 +4485,6 @@
         }
     }
 
-    if (lys_node_addchild(parent, lys_main_module(module), retval)) {
-        goto error;
-    }
-
     LY_TREE_FOR(yin->child, sub) {
         if (!strcmp(sub->name, "refine")) {
             r = fill_yin_refine(module, sub, &uses->refine[uses->refine_size]);