public List<Integer> inorderTraversal(TreeNode root) {
List<Integer> res = new ArrayList<Integer>();
if(root != null) {
Stack<TreeNode> s = new Stack();
s.push(root);
while(!s.empty()){
while(root != null && root.left != null){
s.push(root.left);
root = root.left;
}
root = s.pop();
res.add(root.val);
root = root.right;
if(root != null)
s.push(root);
}
}
return res;
}