List<PsiElement> (PsiElement e, StubElement stub) { final List<PsiElement> result = new ArrayList<>(); if (stub != null) { final List<StubElement> children = stub.getChildrenStubs(); for (StubElement child : children) { result.add(child.getPsi()); } } else { e.acceptChildren(new TopLevelVisitor() { @Override protected void checkAddElement(PsiElement node) { result.add(node); } }); } return result; }