PyStatementList (@NotNull PsiFile file, int offset) { final PsiWhiteSpace whitespace = findWhitespaceAtCaret(file, offset); if (whitespace == null) { return null; } PyStatementList statementList = ObjectUtils.chooseNotNull(as(whitespace.getNextSibling(), PyStatementList.class), as(whitespace.getPrevSibling(), PyStatementList.class)); if (statementList == null) { final PsiElement prevLeaf = getPrevNonCommentLeaf(whitespace); if (prevLeaf instanceof PsiErrorElement) { statementList = as(prevLeaf.getParent(), PyStatementList.class); } } return statementList != null && statementList.getStatements().length == 0 ? statementList : null; }