Bugfix: collect orphaned items during tree generation
at the end of the tree.
Add debugging sanity checks.

1 file changed