Both iterative and recursive | Faster than 95% | Easy to Understand | Simple | Python
\n     def iterative(self, root):\n        if not root: return []\n        stack = [root]\n        out = []\n        while len(stack):\n            top = stack.
```\n     def iterative(self, root):\n        if not root: return []\n        stack = [root]\n        out = []\n        while len(stack):\n            top = stack.pop()\n            out.append(top.val)\n            stack.extend(top.children or [])\n        return out[::-1]\n \n            \n```\n\t\t\t\n\t\t\t\n    \n    def recursive(self, root):\n        def rec(root):\n            if root:\n                for c in root.children:\n                    rec(c)\n                out.append(root.val)\n        \n        out = []\n        rec(root)\n        return out\n\t\t\n\t\t\n**I hope that you\'ve found them useful.**\n*Please do upvote, it only motivates me to write more such post\uD83D\uDE03*
['Recursion', 'Iterator', 'Python', 'Python3']