public ArrayList<Integer> inorderTraversal(TreeNode root) {
    	Stack<Boolean> needExp = new Stack<Boolean>();
    	Stack<TreeNode> visit = new Stack<TreeNode>();
    	ArrayList<Integer> res = new ArrayList<Integer>();
    	if(root == null) return res;
    	needExp.push(true);
    	visit.push(root);
    	while(visit.size() > 0){
    		TreeNode node = visit.pop();
    		if(needExp.pop()){
    			if(node.right != null){
    				visit.push(node.right);
    				needExp.push(true);
    			}
    			visit.push(node);
    			needExp.push(false);
    			if(node.left != null){
    				visit.push(node.left);
    				needExp.push(true);
    			}
    		} else res.add(node.val);
    	}
    	return res;
    }