ASTNode (ASTNode current, final IElementType expected, boolean forward) { while (current != null) { if (current.getElementType() == expected) return current; current = forward ? current.getTreeNext() : current.getTreePrev(); } return null; }