PsiElement (PsiElement element, @NotNull NodeFilter filter) { FilteringNodeIterator it = new FilteringNodeIterator(SiblingNodeIterator.create(element.getFirstChild()), filter); PsiElement child = it.current(); if (child != null) { it.advance(); if (!it.hasNext()) { return child; } } return element; }