Calculate depth, print preorder, print levels