PyReferenceExpression (@Nullable PsiElement exceptExpression) { if (exceptExpression instanceof PyReferenceExpression && "ExceptionGroup".equals(((PyReferenceExpression)exceptExpression).getName())) { return (PyReferenceExpression)exceptExpression; } if (exceptExpression instanceof PyParenthesizedExpression) { return tryGetExceptionGroupInExpression(PyPsiUtils.flattenParens((PyParenthesizedExpression)exceptExpression)); } if (exceptExpression instanceof PyTupleExpression) { for (PsiElement child: exceptExpression.getChildren()) { var result = tryGetExceptionGroupInExpression(child); if (result != null) { return result; } } } return null; }