public static ArrayList<Integer> postorderTraversal(TreeNode root) {
		// write your code here
		Stack<TreeNode> s=new Stack<>();
		ArrayList<Integer>rel=new ArrayList<>();
		TreeNode p=null, c=root;
		while (c!=null||!s.isEmpty()) {
			if (c!=null) {
				s.push(c);
				c=c.left;
			}
			if (c==null) {
				c=s.peek();
				if (c.right==null||c.right==p) {
					p=c;
					rel.add(c.val);
					s.pop();
					c=null;
				} else 
					c=c.right;
			}
		}
		return rel;
	}