private static <T extends Comparable<?>> int maxLevel(Node node) { if (node == null) return 0; return Math.max(BTreePrinter.maxLevel(node.getLeft()), BTreePrinter.maxLevel(node.getRight())) + 1; }
public static <T extends Comparable<?>> void printNode(Node root) { int maxLevel = BTreePrinter.maxLevel(root); printNodeInternal(Collections.singletonList(root), 1, maxLevel); }