Collect child paths before visiting children.

This makes the traversal robust to modifications of ancestor path values,
such as removing a parent path while traversing that parent path.