boolean (Location location) { PsiElement element = location.getPsiElement(); while (true) { final PyIfStatement ifStatement = PsiTreeUtil.getParentOfType(element, PyIfStatement.class); if (ifStatement == null) { break; } element = ifStatement; } if (element instanceof PyIfStatement) { PyIfStatement ifStatement = (PyIfStatement)element; return PyUtil.isIfNameEqualsMain(ifStatement); } return false; }