ModCommand (@NotNull PsiFile file, @Nullable TrackingRunner.CauseItem root) { Project project = file.getProject(); PsiFile topLevelFile = InjectedLanguageManager.getInstance(project).getTopLevelFile(file); Document document = topLevelFile.getViewProvider().getDocument(); List<CauseWithDepth> causes; if (root == null) { causes = Collections.emptyList(); } else { causes = StreamEx.ofTree(new CauseWithDepth(null, root, document), cwd -> cwd.myCauseItem.children() .map(child -> new CauseWithDepth(cwd, child, document))).skip(1).toList(); } if (causes.isEmpty()) { return ModCommand.error(JavaAnalysisBundle.message("dfa.find.cause.unable")); } return new ModChooseAction(StringUtil.wordsToBeginFromUpperCase(root.toString()), ContainerUtil.map(causes, NavigateToCauseAction::new)); }