PySequenceExpression (@NotNull Editor editor, @NotNull PsiFile psiFile) { final int caretOffset = editor.getCaretModel().getOffset(); final PsiElement curElem = psiFile.findElementAt(caretOffset); final PySequenceExpression seqExpr = PsiTreeUtil.getParentOfType(curElem, PySequenceExpression.class); if (seqExpr != null) { return seqExpr; } final PyParenthesizedExpression paren = (PyParenthesizedExpression)PsiTreeUtil.findFirstParent(curElem, element -> { final PyParenthesizedExpression parenthesizedExpr = as(element, PyParenthesizedExpression.class); return parenthesizedExpr != null && parenthesizedExpr.getContainedExpression() instanceof PyTupleExpression; }); return paren != null ? ((PyTupleExpression)paren.getContainedExpression()) : null; }