4 Python Solutions
Hope it helps\n\n\n"""\n# Definition for a Node.\nclass Node:\n    def __init__(self, val=None, children=None):\n        self.val = val\n        self.children =
Hope it helps\n\n```\n"""\n# Definition for a Node.\nclass Node:\n    def __init__(self, val=None, children=None):\n        self.val = val\n        self.children = children\n"""\n\n# Approach 1: Recursive\nclass Solution:\n    def postorder(self, root: \'Node\') -> List[int]:\n        if not root:\n            return []\n\n        def traversal(root):\n            for child in root.children:\n                traversal(child)\n            postorder_traversal.append(root.val)\n\n        postorder_traversal = []\n        traversal(root)\n        return postorder_traversal\n\n\n# Approach 2: Iterative\nclass Solution:\n    def postorder(self, root: \'Node\') -> List[int]:\n        if not root:\n            return []\n        postorder_traversal = []\n        stack = [[root, False]]\n        while stack:\n            curr, visited = stack.pop()\n            if visited:\n                postorder_traversal.append(curr.val)\n            else:\n                stack.append([curr, True])\n                children = len(curr.children)\n                for i in range(children - 1, -1, -1):\n                    stack.append([curr.children[i], False])\n        return postorder_traversal\n\n\n# Approach 3: Recursive Modified Preorder\nclass Solution:\n    def postorder(self, root: \'Node\') -> List[int]:\n        if not root:\n            return []\n\n        def traversal(root):\n            preorder_modified.append(root.val)\n            children = len(root.children)\n            for i in range(children - 1, -1, -1):\n                traversal(root.children[i])\n\n        preorder_modified = []\n        traversal(root)\n        return preorder_modified[::-1]\n\n\n# Approach 4: Iterative Modified Preorder\nclass Solution:\n    def postorder(self, root: \'Node\') -> List[int]:\n        if not root:\n            return []\n        stack = [root]\n        preorder_modified = []\n        while stack:\n            curr = stack.pop()\n            preorder_modified.append(curr.val)\n            for child in curr.children:\n                stack.append(child)\n        return preorder_modified[::-1]\n\n```
['Stack', 'Recursion', 'Iterator', 'Python', 'Python3']