private Node addArrayMember(
            String part,
            boolean isLast,
            ArrayNode container,
            Node value,
            int partPosition,
            boolean intermediate
    ) {
        if (!isLast) {
            // "-" is a special case for the last element.
            int partInt = part.equals("-") ? container.size() - 1 : parseIntPart(part);
            if (container.get(partInt).isPresent()) {
                // Can only traverse into actual array elements.
                Node item = container.get(partInt).get();
                List<Node> list = new ArrayList<>(container.getElements());
                list.set(partInt, addValue(item, value, partPosition + 1, intermediate));
                return new ArrayNode(list, container.getSourceLocation());
            } else {
                logInvalidArrayIndex(container, partInt);
                return container;
            }
        } else if (part.equals("-")) {
            // Special case pushing to the end of the array.
            return container.withValue(value);
        } else {
            // Add the value before the given index.
            int partInt = parseIntPart(part);
            if (partInt > -1 && container.size() >= partInt) {
                List<Node> list = new ArrayList<>(container.getElements());
                list.add(partInt, value);
                return new ArrayNode(list, container.getSourceLocation());
            } else {
                // The index must exist!
                logInvalidArrayIndex(container, partInt);
                return container;
            }
        }
    }
Adds or replaces a {@code value} in {@code container} at the
JSON pointer location.

<p>When the JSON pointer is "", the entire document is replaced with the
given {@code value}. "-" can be used to access the last element of an array
or to add an element to the end of an array. Unlike {@link #addValue(Node, Node)},
attempting to add a property to a non-existent object will create a
new object and continue adding to the created result.

@param container Node to update.
@param value Value to update or replace.
@return Returns a representation of {@code container} with the updated value.
smithy-model/src/main/java/software/amazon/smithy/model/node/NodePointer.java