public AccountIndex findSimilarExistingIndex(AccountIndex index) {
    if (indexExists(index)) {
      return index;
    }
    if (index.getIssuer() == null) {
      return null;  // Nothing else can be "similar" when there is no issuer
    }

    Cursor cursor = getIssuerCursor(index.getIssuer());
    try {
      if (cursor == null) {
        return null;
      }
      int nameIndex = cursor.getColumnIndex(AccountDb.NAME_COLUMN);
      while (cursor.moveToNext()) {
        AccountIndex cursorIndex = new AccountIndex(cursor.getString(nameIndex), index.getIssuer());
        if (index.getStrippedName().equals(cursorIndex.getStrippedName())) {
          return cursorIndex;
        }
      }
    } finally {
      tryCloseCursor(cursor);
    }
    return null;
  }
Tries to find the specified {@link AccountIndex} in the database, and failing that, will find
the first "similar" index in the database. Here, "similar" means that the index has a matching
non-null issuer and the stripped name of the account matches.

@see AccountIndex#getStrippedName()
@return the same {@code index} or a "similar" one with the same issuer that already exists
  in the database, or {@code null} if nothing similar is found
java/com/google/android/apps/authenticator/otp/AccountDb.java