Set<MavenArtifact> (@NotNull List<MavenSimpleNode> selectedNodes) { Set<MavenArtifact> result = new HashSet<>(); List<ProjectNode> projectNodes = filterNodesByClass(selectedNodes, ProjectNode.class); if (!projectNodes.isEmpty()) { for (ProjectNode each : projectNodes) { result.addAll(each.getMavenProject().getDependencies()); } return result; } List<BaseDependenciesNode> baseDependenciesNodes = filterNodesByClass(selectedNodes, BaseDependenciesNode.class); for (BaseDependenciesNode each : baseDependenciesNodes) { if (each instanceof DependenciesNode) { result.addAll(each.getMavenProject().getDependencies()); } else { result.add(((DependencyNode)each).getArtifact()); } } return result; }