void (@NotNull PsiElement psiElement, @NotNull Set<VirtualFile> roots, @NotNull List<Object> model, @Nullable DataContext dataContext, @Nullable NavBarModelExtension ownerExtension) { List<NavBarModelExtension> extensions = NavBarModelExtension.EP_NAME.getExtensionList(); for (PsiElement e = normalize(psiElement, ownerExtension), next = null; e != null; e = normalize(next, ownerExtension), next = null) { // check if we're running circles due to getParent()->normalize/adjust() if (model.contains(e)) break; model.add(e); // check if a root is reached VirtualFile vFile = PsiUtilCore.getVirtualFile(e); if (roots.contains(vFile)) break; for (NavBarModelExtension ext : extensions) { PsiElement parent = ext.getParent(e); if (parent != null && parent != e) { //noinspection AssignmentToForLoopParameter next = parent; break; } } } }