polished tree printing code