public ArrayList<Integer> inorderTraversal(TreeNode root) {
		// the nodes is used to store the result
		ArrayList<Integer> nodes = new ArrayList<Integer>();
		if (root == null)
			return nodes;
		Stack<TreeNode> stack = new Stack<TreeNode>();
		TreeNode node = root;
		// note in the begin of the loop, stack is empty,
		// so we need node != null to make sure the while-loop
		// can be executed.
		while (node != null || !stack.isEmpty()) {
			// if the node is not null,
			// we should get the left child
			if (node != null) {
				stack.push(node);
				node = node.left;
			}
			// if the node is null
			// i.e. reach the situation that the parent
			// don't have left child.
			// we should pop the top of the stack,
			// and do the operation on the right child.
			else {
				node = stack.pop();
				nodes.add(node.val);
				node = node.right;
			}

		}
		return nodes;
	}