easy dfs solution
\n\n# Code\njava []\n/*\n// Definition for a Node.\nclass Node {\n    public int val;\n    public List<Node> children;\n\n    public Node() {}\n\n    public Nod
\n\n# Code\n```java []\n/*\n// Definition for a Node.\nclass Node {\n    public int val;\n    public List<Node> children;\n\n    public Node() {}\n\n    public Node(int _val) {\n        val = _val;\n    }\n\n    public Node(int _val, List<Node> _children) {\n        val = _val;\n        children = _children;\n    }\n};\n*/\n\nclass Solution {\n    public List<Integer> postorder(Node root) {\n        // If the root is null, return an empty list\n        if (root == null) return new ArrayList<>();\n\n        List<Integer> res = new ArrayList<>();\n\n        // Start DFS from the root\n        dfs(root, res);\n\n        // Return the result list containing node values in post-order\n        return res;\n    }\n\n    private void dfs(Node root, List<Integer> res) {\n        // Recursively call dfs for each child of the current node\n        for (Node child : root.children) {\n            dfs(child, res);\n        }\n        // Append the value of the current node to the result list\n        res.add(root.val);\n    }\n}\n```\n```python []\nclass Solution(object):\n    def postorder(self, root):\n        # If the root is None, return an empty list\n        if not root:\n            return []\n\n        res = []\n\n        # Define the DFS function\n        def dfs(root):\n            # Recursively call dfs for each child of the current node\n            for x in root.children:\n                dfs(x)\n            # Append the value of the current node to the result list\n            res.append(root.val)\n\n        # Start DFS from the root\n        dfs(root)\n\n        # Return the result list containing node values in post-order\n        return res\n```
['Tree', 'Depth-First Search', 'Java', 'Python3']