public void postorder(TreeNode root)
    {
        Stack<TreeNode> stack = new Stack<TreeNode>();
        stack.push(new TreeNode(-1));
        Map<TreeNode, Integer> map = new HashMap<TreeNode, Integer>();
        
        TreeNode node = root;
        while(!stack.isEmpty()){
            if (node != null)
            {
                stack.push(node);
                map.put(node, 1);
                node = node.left;
            }
            else
            {
                node = stack.peek();
                if (map.get(node) == 1)
                {
                    map.put(node, 2);
                    node = node.right;
                }
                else if (map.get(node) == 2)
                {
                    node = stack.pop();
                    visit(node);
                    node = null;
                }
            }
        }
    }