private int getAvailableAppKeyIndex() {
        if (appKeys.isEmpty()) {
            return 0;
        } else {
            Collections.sort(appKeys, appKeyComparator);
            final int index = appKeys.size() - 1;
            return appKeys.get(index).getKeyIndex() + 1;
        }
    }
Adds an app key to the list of keys with the given key index. If there is an existing key with the same index,
an illegal argument exception is thrown.

@param newAppKey application key
@throws IllegalArgumentException if app key already exists
mesh/src/main/java/no/nordicsemi/android/mesh/BaseMeshNetwork.java