List<StructureViewTreeElement> (@NotNull PsiElement element, @NotNull Collection<StructureViewTreeElement> baseChildren, boolean withCustomRegions) { List<StructureViewTreeElement> result = new ArrayList<>(withCustomRegions ? CustomRegionStructureUtil.groupByCustomRegions(element, baseChildren) : baseChildren); StructureViewFactoryEx structureViewFactory = StructureViewFactoryEx.getInstanceEx(element.getProject()); Class<? extends PsiElement> aClass = element.getClass(); for (StructureViewExtension extension : structureViewFactory.getAllExtensions(aClass)) { StructureViewTreeElement[] children = extension.getChildren(element); if (children != null) { ContainerUtil.addAll(result, children); } extension.filterChildren(result, children == null || children.length == 0 ? Collections.emptyList() : Arrays.asList(children)); } return result; }