private void chooseAndImport(@NotNull Editor editor, @NotNull Project project) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      doImport(myCandidates.get(0));
      return;
    }
    BaseListPopupStep<T> step =
      new BaseListPopupStep<>(getPopupTitle(), myCandidates) {

        @Override
        public boolean isAutoSelectionEnabled() {
          return false;
        }

        @Override
        public boolean isSpeedSearchEnabled() {
          return true;
        }

        @Override
        public PopupStep<?> onChosen(T selectedValue, boolean finalChoice) {
          if (selectedValue == null) {
            return FINAL_CHOICE;
          }

          if (finalChoice) {
            return doFinalStep(() -> {
              PsiDocumentManager.getInstance(project).commitAllDocuments();
              if (selectedValue.isValid()) {
                doImport(selectedValue);
              }
            });
          }

          return AddImportAction.getExcludesStep(project, PsiUtil.getMemberQualifiedName(selectedValue));
        }

        @Override
        public boolean hasSubstep(T selectedValue) {
          return true;
        }

        @Override
        public @NotNull String getTextFor(T value) {
          return getElementPresentableName(value);
        }

        @Override
        public Icon getIconFor(T aValue) {
          return ReadAction.compute(() -> aValue.getIcon(0));
        }
      };

    JBPopup popup = JBPopupFactory.getInstance().createListPopup(project, step, superRenderer -> {
      GroupedItemsListRenderer<T> rightArrow = (GroupedItemsListRenderer<T>)superRenderer;
      StaticMemberRenderer psiRenderer = new StaticMemberRenderer();
      return (ListCellRenderer<T>)(list, value, index, isSelected, cellHasFocus) -> {
        JPanel panel = new JPanel(new BorderLayout());
        Component psiRendererComponent = psiRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        rightArrow.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        JLabel arrowLabel = rightArrow.getNextStepLabel();
        arrowLabel.setBackground(psiRendererComponent.getBackground());
        panel.setBackground(psiRendererComponent.getBackground());
        panel.add(psiRendererComponent, BorderLayout.CENTER);
        panel.add(arrowLabel, BorderLayout.EAST);
        return panel;
      };
    });
    popup.showInBestPositionFor(editor);
  }
private void chooseAndImport(@NotNull Editor editor, @NotNull Project project)