PyStatementList (@NotNull PsiElement element) { PyStatementList statementList = null; // First whitespace right before the statement list (right after ":") if (element instanceof PsiWhiteSpace) { statementList = as(element.getNextSibling(), PyStatementList.class); } if (statementList == null) { statementList = PsiTreeUtil.getParentOfType(element, PyStatementList.class, false); } return statementList; }