@NotNull
  @Override
  public Collection<? extends AbstractTreeNode<?>> getChildren() {
    Project project = Objects.requireNonNull(getProject());
    List<AbstractTreeNode<?>> children = new ArrayList<>();
    ProjectFileIndex fileIndex = ProjectFileIndex.getInstance(project);
    Module[] modules = ModuleManager.getInstance(project).getModules();
    Map<String, List<Library>> processedLibraries = new HashMap<>();
    Set<Sdk> processedSdk = new HashSet<>();

    for (Module module : modules) {
      final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
      final OrderEntry[] orderEntries = moduleRootManager.getOrderEntries();
      for (final OrderEntry orderEntry : orderEntries) {
        if (orderEntry instanceof LibraryOrderEntry libraryOrderEntry) {
          final Library library = libraryOrderEntry.getLibrary();
          if (library == null) continue;
          String libraryPresentableName = libraryOrderEntry.getPresentableName();
          List<Library> librariesWithSameName = processedLibraries.getOrDefault(libraryPresentableName, new ArrayList<>());
          if (ContainerUtil.exists(librariesWithSameName, processedLibrary -> processedLibrary.hasSameContent(library))) continue;
          librariesWithSameName.add(library);
          processedLibraries.put(libraryPresentableName, librariesWithSameName);

          if (!hasExternalEntries(fileIndex, libraryOrderEntry)) continue;

          final String libraryName = library.getName();
          if (libraryName == null || libraryName.isEmpty()) {
            addLibraryChildren(libraryOrderEntry, children, project, this);
          }
          else {
            children.add(new NamedLibraryElementNode(project, new NamedLibraryElement(null, libraryOrderEntry), getSettings()));
          }
        }
        else if (orderEntry instanceof JdkOrderEntry jdkOrderEntry) {
          final Sdk jdk = jdkOrderEntry.getJdk();
          if (jdk != null) {
            if (processedSdk.contains(jdk)) continue;
            processedSdk.add(jdk);
            children.add(new NamedLibraryElementNode(project, new NamedLibraryElement(null, jdkOrderEntry), getSettings()));
          }
        }
      }
    }
    for (AdditionalLibraryRootsProvider provider : AdditionalLibraryRootsProvider.EP_NAME.getExtensionList()) {
      Collection<SyntheticLibrary> libraries = provider.getAdditionalProjectLibraries(project);
      for (SyntheticLibrary library : libraries) {
        if (library.isShowInExternalLibrariesNode()) {
          if (!(library instanceof ItemPresentation)) {
            LOG.warn("Synthetic library must implement ItemPresentation to be shown in External Libraries node: "
                     + libraries.getClass().getSimpleName());
            continue;
          }
          children.add(new SyntheticLibraryElementNode(project, library, (ItemPresentation)library, getSettings()));
        }
      }
    }
    List<ExternalLibrariesWorkspaceModelNodesProvider<?>> extensionList =
      ExternalLibrariesWorkspaceModelNodesProvider.EP.getExtensionList();
    if (!extensionList.isEmpty()) {
      ImmutableEntityStorage current = WorkspaceModel.getInstance(project).getCurrentSnapshot();
      for (ExternalLibrariesWorkspaceModelNodesProvider<?> provider : extensionList) {
        handleProvider(provider, project, current, children);
      }
    }
    return children;
  }
@NotNull
  @Override
  public Collection<? extends AbstractTreeNode<?>> getChildren()