public static void postorder(TreeNode root) {
		if (root == null)
			return;
		
		Stack<TreeNode> S = new Stack<TreeNode>();
		S.push(root);
		
		TreeNode previous = null;
		
		while (!S.empty()) {
			//get the current node from the stack
			TreeNode current = S.peek();
			
			//going down the tree
			if (previous == null 
					|| previous.left == current
					|| previous.right ==current) {
				if (current.left != null)
					S.push(current.left);
				else if (current.right != null)
					S.push(current.right);
				else {
					current.print();
					S.pop();
				}
			}
			// left sub tree is traversed
			else if (current.left == previous) {
				if (current.right != null)
					S.push(current.right);
				else {
					current.print();
					S.pop();
				}
			}
			//both subtrees are processed
			else {
				current.print();
				S.pop();
			}
			
			previous = current;
		} //end of while
		
		System.out.println();
	}