public ArrayList<Integer> postorderTraversal(treeNode root) {
		ArrayList<Integer> valsInPostOrder = new ArrayList<Integer>();
		Stack<treeNode> nodesInPostOrder = new Stack<treeNode>();
		ArrayList<treeNode> visited = new ArrayList<treeNode>();

		if (root == null)
			return valsInPostOrder;

		// push root in to begin with
		nodesInPostOrder.push(root);

		treeNode curNode = null;
		while (!nodesInPostOrder.isEmpty()) {
			// peek at the topmost node
			curNode = nodesInPostOrder.peek();
			// if it has no children or visited before then pop and add to array
			if ((curNode.leftLeaf == null && curNode.rightLeaf == null)
					|| visited.contains(curNode)) {
				nodesInPostOrder.pop();
				valsInPostOrder.add(new Integer(curNode.value));
			} else {// else push children in right/left order, so left would be
					// visited sooner later
				visited.add(curNode); // mark as visited
				if (curNode.rightLeaf != null)
					nodesInPostOrder.push(curNode.rightLeaf);
				if (curNode.leftLeaf != null)
					nodesInPostOrder.push(curNode.leftLeaf);
			}
		}

		return valsInPostOrder;
	}