Tree walker function to collect all possible keys from an object recursively
This function traverses an object tree and collects all property keys at any
depth. It handles arrays, nested objects, and prevents infinite loops from
circular references.
Parameters
obj: unknown
The object to walk through
keys: Set<string|number|symbol> = ...
Set to collect all keys (optional, used for recursion)
visited: WeakSet<object> = ...
Set to track visited objects to prevent circular references
(optional, used for recursion)
Tree walker function to collect all possible keys from an object recursively
This function traverses an object tree and collects all property keys at any depth. It handles arrays, nested objects, and prevents infinite loops from circular references.