data tree REFACTOR use common union in all data nodes

Also, now redundant casting removed where possible.
Fixes #1388
diff --git a/src/parser_json.c b/src/parser_json.c
index e84ee97..8fd2f06 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -165,7 +165,7 @@
             *prefix_p = onode->name.prefix;
             break;
         }
-        node = (struct lyd_node *)node->parent;
+        node = lyd_parent(node);
     }
     *prefix_len_p = ly_strlen(module_name);
 
@@ -198,7 +198,7 @@
     /* init return value */
     *snode_p = NULL;
 
-    LOG_LOCSET(NULL, (const struct lyd_node *)parent, NULL, NULL);
+    LOG_LOCSET(NULL, &parent->node, NULL, NULL);
 
     /* get the element module */
     if (prefix_len) {
@@ -831,7 +831,7 @@
 {
     if (*node_p) {
         /* insert, keep first pointer correct */
-        lyd_insert_node((struct lyd_node *)parent, first_p, *node_p);
+        lyd_insert_node(&parent->node, first_p, *node_p);
         if (first_p) {
             if (parent) {
                 *first_p = parent->child;
@@ -889,7 +889,7 @@
     }
 
     /* create node */
-    lydjson_get_node_prefix((struct lyd_node *)parent, prefix, prefix_len, &module_name, &module_name_len);
+    lydjson_get_node_prefix(&parent->node, prefix, prefix_len, &module_name, &module_name_len);
     ret = lyd_create_opaq(lydctx->jsonctx->ctx, name, name_len, prefix, prefix_len, module_name, module_name_len, value,
             value_len, &dynamic, LY_PREF_JSON, NULL, type_hint, node_p);
     if (dynamic) {
@@ -1188,7 +1188,7 @@
                 ret = LY_EVALID;
                 goto cleanup;
             }
-            attr_node = (struct lyd_node *)parent;
+            attr_node = &parent->node;
             snode = attr_node->schema;
         }
         ret = lydjson_parse_attribute(lydctx, attr_node, snode, name, name_len, prefix, prefix_len, parent, &status,
@@ -1296,7 +1296,7 @@
     goto cleanup;
 
 representation_error:
-    LOG_LOCSET(NULL, (const struct lyd_node *)parent, NULL, NULL);
+    LOG_LOCSET(NULL, &parent->node, NULL, NULL);
     LOGVAL(ctx, LYVE_SYNTAX_JSON, "The %s \"%s\" is expected to be represented as JSON %s, but input data contains name/%s.",
             lys_nodetype2str(snode->nodetype), snode->name, expected, lyjson_token2str(status));
     LOG_LOCBACK(0, parent ? 1 : 0, 0, 0);