added a single generic method that can print tree in pre, in or post order