boolean (PsiElement child, PsiElement first, PsiElement last) { if (child.equals(first)) return true; while (true) { if (child.equals(first)) return false; // before first if (child.equals(last)) return true; child = child.getNextSibling(); if (child == null) return false; } }