Set<String> (@NotNull Module module) { Node start = myGraph.myNodes.get(module); if (start == null) return Collections.emptySet(); Deque<Node> stack = new ArrayDeque<>(); stack.push(start); Set<Node> seen = new HashSet<>(); Set<String> result = null; while (!stack.isEmpty()) { Node node = stack.pop(); if (!seen.add(node)) { continue; } if (node.myUnloadedDependentModules != null) { if (result == null) { result = new LinkedHashSet<>(node.myUnloadedDependentModules); } else { result.addAll(node.myUnloadedDependentModules); } } for (Edge edge : node.myEdges) { if (edge.myRecursive) { Node targetNode = myGraph.myNodes.get(edge.myKey); if (targetNode != null) { stack.push(targetNode); } } } } return result != null ? result : Collections.emptySet(); }