Set<String> (@NotNull Language language, boolean applyToDialects) { List<Language> dialects = language.getDialects(); if (!applyToDialects || dialects.isEmpty()) return Set.of(language.getID()); Collection<@NotNull Language> transitiveDialects = language.getTransitiveDialects(); Set<String> result = new HashSet<>(1 + transitiveDialects.size()); result.add(language.getID()); for (Language dialect : transitiveDialects) { result.add(dialect.getID()); } return result; }