debugged minst, preorder traversal