Implement setAt(root, path, value), an immutable nested update for JSON-like data. path is an array of string property names. Empty path returns value. For a nonempty path, each traversed existing parent must be a non-null, non-array object; otherwise throw TypeError. Missing intermediate properties create objects. Values at the leaf may be any JSON value.
Copy only changed ancestors along the path. Preserve the exact reference of untouched branches, do not mutate any input, and return the original root for a no-op update where the existing leaf is Object.is-equal to value. Reject non-array paths, non-string segments, and any segment equal to proto, constructor, or prototype with TypeError before updating. Inputs contain no getters, symbols, cycles, or custom prototypes.