code: private int binarySearchNonUnique(int fromIndex, int toIndex, long key1, long key2) {
  		int low = fromIndex;
  		int high = toIndex - 1;
  
  		while (low <= high) {
  			int mid = (low + high) >>> 1;
  			long midVal1 = keys[mid];
  			long midVal2 = values[mid];
  
          	if (midVal1 < key1) {
          		low = mid + 1;
          	} else if (midVal1 > key1) {
          		high = mid - 1;
          	} else {
              	if (midVal2 < key2) {
              		low = mid + 1;
              	} else if (midVal2 > key2) {
              		high = mid - 1;
              	} else {
              		return mid; // key found
              	}
          	}
  		}
  		return -(low + 1);  // key not found.
  	}
docs: This effectively implements a binary search of a double-long array (128bit values).