private Node addWithFlag(Node container, Node value, boolean intermediate) {
        // Special case for replacing the entire document.
        if (parts.isEmpty()) {
            return value;
        } else {
            return addValue(container, value, 0, intermediate);
        }
    }
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