private Node addValue(Node container, Node value, int partPosition, boolean intermediate) {
        String part = parts.get(partPosition);
        boolean isLast = partPosition == parts.size() - 1;

        if (container.isObjectNode()) {
            return addObjectMember(part, isLast, container.expectObjectNode(), value, partPosition, intermediate);
        } else if (container.isArrayNode()) {
            return addArrayMember(part, isLast, container.expectArrayNode(), value, partPosition, intermediate);
        } else {
            LOGGER.warning(() -> String.format(
                    "Attempted to add a value through JSON pointer `%s`, but segment %d targets %s",
                    toString(),
                    partPosition,
                    Node.printJson(container)));
            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