Keeps only the top-level children whose names match names (in tree
order), reindexing the remaining leaves so they map to contiguous positions
in a flat list. The kept children are put under a list root, also when the
root of tree is an object node.
Arguments
- tree
(
RTree)
A tree whose root is a named list or object node, as returned bybuild_tree().- names
(
character())
Names of children to keep.