/**
 * This function takes a nested dictionary as input and counts the number of individuals of each species in the population.
 *
 * @param population A nested dictionary representing the population.
 * @return A dictionary containing the count of individuals for each species.
 */
fun countSpeciesPopulation(population: Map<String, Map<String, List<String>?>?>): Map<String, Int> {

    val speciesCount = mutableMapOf<String, Int>()  // Initialize an empty dictionary to store the count of individuals for each species
    for ((species, locationDict) in population) {
        for ((_, individuals) in locationDict.orEmpty()) {
            individuals?.forEach { individual ->
                if (individual != null) {  // Skip if the individual is null
                    speciesCount[species] = speciesCount.getOrDefault(species, 0) + 1  // Increment the count for the species
                }
            }
        }
    }
    return speciesCount
}
/**
 * This function takes a nested dictionary as input and counts the number of individuals of each species in the population.
 *
 * @param population A nested dictionary representing the population.
 * @return A dictionary containing the count of individuals for each species.
 */
fun countSpeciesPopulation(population: Map<String, Map<String, List<String>?>?>): Map<String, Int> {
/**
 * This function takes a nested dictionary as input and counts the number of individuals of each species in the population.
 *
 * @param population A nested dictionary representing the population.
 * @return A dictionary containing the count of individuals for each species.
 */
fun countSpeciesPopulation(population: Map<String, Map<String, List<String>?>?>): Map<String, Int> {

    val speciesCount = mutableMapOf<String, Int>()  // Initialize an empty dictionary to store the count of individuals for each species
    for ((species, locationDict) in population) {
        for ((_, individuals) in locationDict.orEmpty()) {
            individuals?.forEach { individual ->
                if (individual != null) {  // Skip if the individual is null
                    speciesCount[species] = speciesCount.getOrDefault(species, 0) + 1  // Increment the count for the species
                }
            }
        }
    }
    return speciesCount
}