private JsonNode createParentsIfNotExists(JsonNode root, String[] paths, int index) throws IOException {
        if (root == null) {
            return root;
        }

        if (paths == null) {
            return root;
        }
        if (index >= paths.length) {
            return root;
        }

        int arrayIndex = JsonTreeUtil.getArrayIndex(paths[index]);
        JsonNode parent = root.get(normalize(paths[index]));
        if (parent == null) {
            if (JsonTreeUtil.isArrayPath(paths[index])) {
                ArrayNode arrayNode = jsonTreeOperations.arrayNode();
                if (arrayIndex >= 0) {
                    for (int j = 0; j <= arrayIndex; j++) {
                        arrayNode.add(jsonTreeOperations.objectNode());
                    }
                }
                parent = arrayNode;
            } else {
                parent = jsonTreeOperations.objectNode();
            }
            root = root.isArray() ? ((ArrayNode) root).add(parent) : ((ObjectNode) root).put(normalize(paths[index]), parent);
        } else {
            if (arrayIndex >= 0) {
                if (!parent.isArray()) {
                    throw new IOException("Parent found to be non-array node while the path claims to be an array " + paths[index]);
                }
                ArrayNode arrayNode = (ArrayNode) parent;
                for (int j = 0; j <= arrayIndex; j++) {
                    if (arrayNode.get(j) == null) {
                        arrayNode.add(jsonTreeOperations.objectNode());
                    }
                }
            }
        }
        return createParentsIfNotExists(parent, paths, index + 1);
    }
Prepares the parent node of the path if array => prepare the array node of
the path and => if indexed , prepares the respective index element => prepare
the object node of the path

@param root
@param paths
@param index
@return
@throws IOException
manifest-generator/generator-services/src/main/java/io/hyscale/generator/services/utils/ManifestTreeUtils.java