void (@NotNull Collection<ExternalDependency> dependencies) { for (Iterator<ExternalDependency> iter = dependencies.iterator(); iter.hasNext(); ) { ExternalDependency nextDependency = iter.next(); ExternalDependencyId nextId = nextDependency.getId(); ExternalDependency seenDependency = seenDependencies.get(nextId); Collection<ExternalDependency> childDeps = nextDependency.getDependencies(); if (seenDependency == null) { seenDependencies.put(nextId, nextDependency); visit(childDeps); } else { upgradeScopeIfNeeded(seenDependency, nextDependency.getScope()); visit(childDeps); seenDependency.getDependencies().addAll(childDeps); if (seenAllFiles(seenDependency, nextDependency)) { iter.remove(); } } } }