boolean (@NotNull Project project, Editor editor, PsiFile file) { if (!(file instanceof PyFile)) { return false; } PyIfStatement expression = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyIfStatement.class); PyIfStatement outer = getIfStatement(expression); if (outer != null) { if (outer.getElsePart() != null || outer.getElifParts().length > 0) return false; PyStatement firstStatement = getFirstStatement(outer); PyStatementList outerStList = outer.getIfPart().getStatementList(); if (outerStList.getStatements().length != 1) return false; if (firstStatement instanceof PyIfStatement inner) { if (inner.getElsePart() != null || inner.getElifParts().length > 0) return false; PyStatementList stList = inner.getIfPart().getStatementList(); if (stList.getStatements().length != 0) return true; } } return false; }