fix multiple-printf bug

this fixes the "multiple-printf" bug.
the problem was that we using walk_tree_without_duplicates --
but rewriting the node itself, so we actually did want to see
duplicates

this also adds some primitive GC support for trees we create.
the approach taken is rather hacky.

and it adds a bit of debugging help so that debug_tree
doesn't try calling into gdb.