def levelOrder(self, root: Optional[TreeNode]) -> List[List[int]]:
    ans = []

    def _larger(n):
        for i in range(len(ans), (n + 1)):
            ans.append([])

    def _traversal(node, depth):
        if (node != None):
            _larger(depth)
            tmp = ans[depth]
            tmp.append(node.val)
            _traversal(node.left, (depth + 1))
            _traversal(node.right, (depth + 1))
    _traversal(root, 0)
    return ans
def levelOrder(self, root: Optional[TreeNode]) -> List[List[int]]:
    ans = []

    def _larger(n):
        for i in range(len(ans), (n + 1)):
            ans.append([])

    def _traversal(node, depth):
        if (node != None):
            _larger(depth)
            tmp = ans[depth]
            tmp.append(node.val)
            _traversal(node.left, (depth + 1))
            _traversal(node.right, (depth + 1))
    _traversal(root, 0)
    return ans