boolean (@NotNull final PsiElement elementToCheck, @NotNull final PyForStatement forStatement) { final PyElsePart elsePart = forStatement.getElsePart(); if (elsePart != null) { if (PsiTreeUtil.isAncestor(elsePart, elementToCheck, false)) { return true; } } return false; }