public static Collection<RunContentDescriptor> findRunningConsole(@NotNull Project project,
                                                                    @NotNull NotNullFunction<? super RunContentDescriptor, Boolean> descriptorMatcher) {
    return ReadAction.compute(() -> {
      RunContentManager contentManager = RunContentManager.getInstance(project);
      final RunContentDescriptor selectedContent = contentManager.getSelectedContent();
      if (selectedContent != null) {
        final ToolWindow toolWindow = contentManager.getToolWindowByDescriptor(selectedContent);
        if (toolWindow != null && toolWindow.isVisible()) {
          if (descriptorMatcher.fun(selectedContent)) {
            return Collections.singletonList(selectedContent);
          }
        }
      }

      final List<RunContentDescriptor> result = new SmartList<>();
      for (RunContentDescriptor runContentDescriptor : contentManager.getAllDescriptors()) {
        if (descriptorMatcher.fun(runContentDescriptor)) {
          result.add(runContentDescriptor);
        }
      }
      return result;
    });
  }
public static Collection<RunContentDescriptor> findRunningConsole(@NotNull Project project,
                                                                    @NotNull NotNullFunction<? super RunContentDescriptor, Boolean> descriptorMatcher)