Set<String> (@NotNull Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> currentInfo, @NotNull Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> oldInfo) { Map<String/* external config path */, String/* project name */> map = new HashMap<>(); for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : currentInfo.entrySet()) { map.put(entry.getKey().getPath(), entry.getKey().getName()); for (ExternalProjectPojo pojo : entry.getValue()) { map.put(pojo.getPath(), pojo.getName()); } } Set<String> result = new HashSet<>(); for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : oldInfo.entrySet()) { String newName = map.get(entry.getKey().getPath()); if (newName != null && !newName.equals(entry.getKey().getName())) { result.add(entry.getKey().getPath()); } for (ExternalProjectPojo pojo : entry.getValue()) { newName = map.get(pojo.getPath()); if (newName != null && !newName.equals(pojo.getName())) { result.add(pojo.getPath()); } } } return result; }