Revert "Revert "abstracted out TreeReader common stuff to TreeBuilder""

This reverts commit 62020ee460e455c2672fe556dfd9d7d463594d1a.