private @Nullable Pair<Content, TerminalWidget> getSuitableProcess(@NotNull Project project,
                                                                     @NotNull ContentManager contentManager,
                                                                     @NotNull String workingDirectory) {
    Content selectedContent = contentManager.getSelectedContent();
    if (selectedContent != null) {
      Pair<Content, TerminalWidget> pair = getSuitableProcess(project, selectedContent, workingDirectory);
      if (pair != null) return pair;
    }

    return Arrays.stream(contentManager.getContents())
      .map(content -> getSuitableProcess(project, content, workingDirectory))
      .filter(Objects::nonNull)
      .findFirst()
      .orElse(null);
  }
private @Nullable Pair<Content, TerminalWidget> getSuitableProcess(@NotNull Project project,
                                                                     @NotNull ContentManager contentManager,
                                                                     @NotNull String workingDirectory)