SortedSet<String> () { TreeSet<String> selected = new TreeSet<>(); for (Map.Entry<String, Boolean> entry : mySelectedFiles.entrySet()) { if (isChecked(entry.getValue())) { selected.add(entry.getKey()); } } return Collections.unmodifiableSortedSet(selected); }