private boolean askAndRemoveDuplicatedLibraryEntry(@NotNull ModifiableRootModel rootModel, @NotNull CustomLibraryDescription description) {
    List<OrderEntry> existingEntries = new ArrayList<>();
    final LibrariesContainer container = myModel.getLibrariesContainer();
    for (OrderEntry entry : rootModel.getOrderEntries()) {
      if (!(entry instanceof LibraryOrderEntry)) continue;
      final Library library = ((LibraryOrderEntry)entry).getLibrary();
      if (library == null) continue;

      if (LibraryPresentationManager.getInstance().isLibraryOfKind(library, container, description.getSuitableLibraryKinds())) {
        existingEntries.add(entry);
      }
    }

    if (!existingEntries.isEmpty()) {
      final String name = existingEntries.get(0).getPresentableName();
      final String message = JavaUiBundle.message("add.support.for.single.framework.remove.duplicates.dialog.message",
                                            existingEntries.size(),
                                            myFrameworkType.getPresentableName(),
                                            name);
      final int result = Messages.showYesNoCancelDialog(rootModel.getProject(), message,
                                                        JavaUiBundle.message("dialog.title.library.already.exists"),
                                                        CommonBundle.message("button.replace.r"),
                                                        CommonBundle.message("button.add.a"),
                                                        CommonBundle.message("button.cancel.c"), null);
      if (result == Messages.YES) {
        for (OrderEntry entry : existingEntries) {
          rootModel.removeOrderEntry(entry);
        }
      }
      else if (result != Messages.NO) {
        return false;
      }
    }
    return true;
  }
private boolean askAndRemoveDuplicatedLibraryEntry(@NotNull ModifiableRootModel rootModel, @NotNull CustomLibraryDescription description)