import java.util.*;

public class Solution {
    ArrayList<Integer> list = new ArrayList<Integer>();
    Stack visited = new Stack();

    public List<Integer> postorderTraversal(TreeNode root) {
      TreeNode node;
      visited.push(root);
      while (visited.size > 0) {
        node = visited.pop();
        if (node.left != null) {
          visited.push(node.left);
        }
        else if (node.right != null) {
          visited.push(node.right);
        }
        else { list.add(node.val); }
      }
      return list;
    }

    public TreeNode getDeepLeft(TreeNode currentNode) {
      while (currentNode.left != null) {
        currentNode = currentNode.left;
      }
      return currentNode;
    }
}

@@ -709,11 +709,475 @@
 e;%0A    %7D
+%0A%0A  public class Stack %7B%0A    ArrayList%3CTreeNode%3E list;%0A    public int size = 0;%0A%0A    public Stack() %7B%0A      list = new ArrayList%3CTreeNode%3E();%0A    %7D%0A%0A    public TreeNode pop() %7B%0A      TreeNode retVal = list.get(list.size()-1);%0A      list.remove(list.remove(list.size()-1));%0A      size--;%0A      return retVal;%0A    %7D%0A%0A    public void push(TreeNode val) %7B%0A      list.add(val);%0A      size++;%0A    %7D%0A%0A    public String toString() %7B%0A      return list.toString();%0A    %7D%0A  %7D
 %0A%7D%0A

Put stack class inside Solution