private String[] expandTofullPath(PathExpansionMode mode, String... xs) {
        if ((mode == PathExpansionMode.Insert && xs.length > mode.maxSize) ||
            (mode == PathExpansionMode.Retrieve && xs.length > mode.maxSize))
            throw new IllegalArgumentException(String.format("max path size for %s is %d, but got %d: %s",
                mode.name(), mode.maxSize, xs.length, U.Str.join(Arrays.asList(xs), "/")));

        final String[] path = new String[PATH_SIZE];
        for(int i=0; i<PATH_SIZE; ++i)
            path[i] = i < xs.length ? xs[i] : "";

        // when inserting last elem is the value to insert
        // when retrieving last elem is the name of the value node (=VAL)
        if (mode == PathExpansionMode.Insert) {
            int valIdx = xs.length - 1;
            String x = path[valIdx];
            path[valIdx] = "";
            path[path.length - 1] = x;
        } else {
            path[path.length - 1] = "VAL";
        }
        return path;
    }