[child extraction] add childStorage() function to directly access the storage of a child
In some contexts, we actually have to access the underlying storage of a node's children (e.g. for proxy nodes). It is important to *not* use `child()` in this situation, as the child might have been allocated on the head (e.g. as part of a tree transformation) and thus might disappear when its parent goes out of scope or is otherwise destroyed. This patch adds a new function `childStorage()` that works just like `child()`, but returns the storage (usually a `std::shared_ptr`) of the child instead. It will fail if the child path is of length zero and the passed-in object is not pointer-like. If it is pointer-like, the algorithm assumes that the pointer represents the storage of the root node and will just return that object.
Showing with 93 additions and 35 deletions