private int getAvailableNetKeyIndex() {
        if (netKeys.isEmpty()) {
            return 0;
        } else {
            Collections.sort(netKeys, netKeyComparator);
            final int index = netKeys.size() - 1;
            return netKeys.get(index).getKeyIndex() + 1;
        }
    }
Adds a Net key to the list of net keys with the given key index

@param newNetKey Network key
@throws IllegalArgumentException if the key already exists.
mesh/src/main/java/no/nordicsemi/android/mesh/BaseMeshNetwork.java