moved printing code into TreePrinter class
TreePrinter supports output parameter