while (((KeyValuePairModell) fKeyValuePairs.get(insertIndex)).compareTo(keyValuePair) < 0) {
int maxMatch = Integer.MIN_VALUE; for (int i=0; i<fKeyValuePairs.size(); i++) { KeyValuePairModell element = (KeyValuePairModell) fKeyValuePairs.get(i); int match = element.compareTo(keyValuePair); if (match >= maxMatch) { insertIndex = i; maxMatch = match; } }  if (insertIndex < fKeyValuePairs.size() - 1) {
    private int findInsertPosition(KeyValuePair keyValuePair) {        int insertIndex = 0;        while (((KeyValuePairModell) fKeyValuePairs.get(insertIndex)).compareTo(keyValuePair) < 0) {            insertIndex++;        }        return insertIndex;    }