[C++ / Image & Intuition] Iterative solution using a stack+unordered_map
Intuition:\nGiven the following tree \n\n\nThe idea is:\n1. When we encounter a node which has children, we check if it has been processed and if it has any chi
**Intuition:**\nGiven the following tree \n![image](https://assets.leetcode.com/users/david_dev/image_1569247765.png)\n\nThe idea is:\n1. When we encounter a node which has children, we check if it has been processed and if it has any children. \n\t* If it has, then we push the value into the `result` vector and pop the stack.\n\t* If not, we mark the current node as processed (with `unordered_map`) and we push its children from right to left into the stack.\n2. When we get to the left-most leaf in the tree, we push the value to the `result` vector and pop the stack. \n\nThe reason with the `unordered_map `is that when we push the nodes in a preorder fashion, we will encounter a node that we already have processed before and thus avoid pushing its children again. This is to avoid an endless loop. \n\nThe best example is when we have pushed all nodes into the stack, the stack will look like this:\n\n1. ```\n\tResult: []\n\tStack: [1,4,2,3,6,5\n\t```\n\tWe pop 5 and 6 as its a leaf node and add it to `result`.\n\n2. ```\n\tResult: [5,6] // added node 5 and 6.\n\tStack: [1,4,2, // pop the stack!\n\t```\n\tNow the top of the stack is 3 which has children of 5 and 6. But we have already processed this node, so we add it to the `result` and pop.\n\n3. ```\n\tResult: [5,6,3] // added node 3 to the result.\n\tStack: [1,4,2 // pop stack\n\t```\n\tNow the top of the stack is 2, which has children. We have not processed this node before so we mark it as processed in our `unordered_map` and push its children. In this case node 10.\n\n4. ```\n\tResult: [5,6,3]\n\tStack: [1,4,2, 10 // We added node 2\'s children which is 10.\n\t```\n\tNow we push 10 into our `result` and pop.\n\n5. ```\n\tResult: [5,6,3, 10] // added 10 to result.\n\tStack: [1,4,2 // pop stack!\n\t```\n\tNow we can see that node 2 has already been processed, we add it to the `result` and pop.\n\n6. ```\n\tResult: [5,6,3, 10, 2] // added 2 to result.\n\tStack: [1,4 // pop stack!\n\t```\n\nAnd so on....\n\n\n**C++ solution**\n```\n\tvector<int> postorder(Node* root) {\n        vector<int> result;\n        if(root == nullptr){\n            return result;\n        }\n        \n        stack<Node*> stk;\n        stk.push(root);\n        unordered_map<Node*, bool> map;\n        while(!stk.empty())\n        {\n            Node* current = stk.top();\n            if(current->children.size() > 0 && map[current] == false){\n                map[current] = true;\n                for(int i = current->children.size()-1; i >= 0; i--){\n                    stk.push(current->children[i]);\n                }\n            }\n            else{\n                result.push_back(current->val);\n                stk.pop();   \n            }\n        }\n        return result;\n    }\n```\n\n**Time Complexity:** O(n^2) where n is the number of nodes in the tree.\n**Space Complexity:** O(n)
['Stack', 'C']