Set<PyRequirement> (@NotNull List<PyPackage> packages, @NotNull Collection<PyRequirement> requirements, @NotNull Set<PyPackage> visited) { final Set<PyRequirement> result = new HashSet<>(); for (PyRequirement req : requirements) { final PyPackage pkg = req.match(packages); if (pkg != null && visited.add(pkg)) { result.addAll(getTransitiveRequirements(packages, pkg.getRequirements(), visited)); } } return result; }