Cell midCell = getCell(mid);
int compareRes = comparator.compare(midCell, needle);
if (compareRes == 0) {
return mid;  // 0 means equals. We found the key
}
<BUG>if (compareRes < 0) {
begin = mid + 1;</BUG>
} else {
end = mid - 1;
}

Cell midCell = getCell(mid);
int compareRes = comparator.compare(midCell, needle);
if (compareRes == 0) {
return mid;  // 0 means equals. We found the key
}
if ((compareRes < 0) ^ descending) {
begin = mid + 1;
} else {
end = mid - 1;
