Subsets a ListNode to keep only the children whose names match names,
then reindexes the leaf nodes so they map to contiguous positions in a flat
list. If all names are kept the original tree is returned unchanged.
Arguments
- tree
(
ListNode)
A named list node as returned bybuild_tree().- names
(character)
Names of children to keep.