Whats wrong with this solution


#1

TreeNode solution(TreeNode root, int a, int b) {
if(root==null) {
return null;
}
while(root!=null) {
if(root.val > a && root.val > b) {
root = root.left;
} else if(root.val<a && root.val<b) {
root = root.right;
} else {
break;
}
}
return root;
}

public int lca(TreeNode A, int B, int C) {


    TreeNode answer = solution(A, B, C);
    
    return answer.val;

}
}