Remove some duplication and allow copytree to reuse the parent's collapse logic