Easy to understand | 2 Solution | DFS | BFS | Simple | Python solution
\n    def recursive(self, root):\n        #inspired by the solution somewhat\n        out = []\n        def rec(node, height):\n            if node:\n          
```\n    def recursive(self, root):\n        #inspired by the solution somewhat\n        out = []\n        def rec(node, height):\n            if node:\n                if len(out) <= height:\n                    out.append([])\n                out[height].append(node.val)\n                rec(node.left, height + 1)\n                rec(node.right, height + 1)\n        rec(root, 0)\n        return [out[i] if i%2==0 else out[i][::-1] for i in range(len(out))]\n    \n    def iterative(self, root):\n        # here, the stack should be replaced by queue but I guess, I am lazy ;)\n        if not root: return []\n        stack = [root]\n        out = []\n        reverse = True\n        while len(stack):\n            temp = []\n            out.append([i.val for i in (stack if reverse else stack[::-1])])\n            reverse = not reverse\n            while len(stack):\n                top = stack.pop(0)\n                if top.left: temp.append(top.left)\n                if top.right: temp.append(top.right)\n            \n            stack = temp\n        return out\n```\n\n**I hope that you\'ve found the solution useful.**\n*In that case, please do upvote and encourage me to on my quest to document all leetcode problems\uD83D\uDE03*\nPS: Search for **mrmagician** tag in the discussion, if I have solved it, You will find it there\uD83D\uDE38
['Depth-First Search', 'Breadth-First Search', 'Python', 'Python3']