PsiElement (@NotNull PsiElement element, boolean forward, @NotNull TokenSet set) { do { if (forward) { element = element.getNextSibling(); } else { element = element.getPrevSibling(); } } while (element != null && element.getNode() != null && set.contains(element.getNode().getElementType())); return element; }