consolidate tree walking loops and add copyToStream method