public static ArrayList<Integer> inorderTraversal(TreeNode root) {
        // write your code here
        ArrayList<Integer> rel=new ArrayList<>();
        Stack<TreeNode>s=new Stack<>();
        TreeNode c=root;
        while (c!=null||!s.isEmpty()) {
            if (c!=null) {
                s.push(c);
                c=c.left;
            }
            if (c==null) {
                c=s.pop();
                rel.add(c.val);
                c=c.right;
            }
        }
        return rel;
    }