to_tree_inverse#
- seli.to_tree_inverse(obj: None | bool | int | float | str | type | Array | ShapeDtypeStruct | list | dict | Module | Any)[source]#
Reconstructs the original object structure from a tree produced by to_tree.
This function is the inverse operation of to_tree. It takes a tree structure where shared or cyclic references have been replaced with PathKey objects, and reconstructs the original structure by resolving those path references back into actual object references.
- Parameters:
obj (NodeType) – A tree structure, typically produced by to_tree, where shared or cyclic references have been replaced with PathKey objects pointing to their location in the tree.
- Returns:
The reconstructed object structure with all path references resolved back into actual object references, restoring the original shared references and cycles.
- Return type:
NodeType
Notes
This function reverses the transformation performed by to_tree
When a PathKey is encountered during traversal, it gets resolved by accessing the object at that path in the tree
The function uses dfs_map internally for traversal, similar to to_tree
While to_tree eliminates cycles by replacing them with path references, this function reintroduces those cycles