public int getNthIterative(TreeNode root, int n){
        if(root == null) return -1;
        Stack<TreeNode> stack = new Stack<TreeNode>();

        while(!stack.isEmpty() || root != null){
            if(root != null){
                stack.push(root);
                root = root.left;
            }else{
                TreeNode node = stack.pop();
                n--;
                if(n == 0) return node.val;
                root = node.right;
            }
        }
        return -1;
    }