Converts a tree from BFS layout to inorder layout