Collection<PsiElement> (@NotNull PsiFile file) { if (!(file instanceof YAMLFile)) return ContainerUtil.emptyList(); Collection<PsiElement> roots = new HashSet<>(); for (YAMLDocument document : ((YAMLFile)file).getDocuments()) { YAMLValue topLevelValue = document.getTopLevelValue(); roots.add(topLevelValue == null ? document : topLevelValue); } return roots; }