void (PsiExpression expression, PsiExpression switchExpression, IfStatementBranch branch) { if (expression instanceof PsiMethodCallExpression methodCallExpression) { final PsiExpressionList argumentList = methodCallExpression.getArgumentList(); final PsiExpression[] arguments = argumentList.getExpressions(); final PsiExpression argument = arguments[0]; final PsiExpression secondArgument = arguments.length > 1 ? arguments[1] : null; final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); final PsiExpression qualifierExpression = methodExpression.getQualifierExpression(); if (EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(switchExpression, argument)) { branch.addCaseExpression(secondArgument == null ? qualifierExpression : secondArgument); } else { branch.addCaseExpression(argument); } } else if (expression instanceof PsiInstanceOfExpression) { branch.addCaseExpression(expression); } else if (expression instanceof PsiPolyadicExpression polyadicExpression) { final PsiExpression[] operands = polyadicExpression.getOperands(); final IElementType tokenType = polyadicExpression.getOperationTokenType(); if (JavaTokenType.OROR.equals(tokenType)) { for (PsiExpression operand : operands) { extractCaseExpressions(operand, switchExpression, branch); } } else if (JavaTokenType.ANDAND.equals(tokenType)) { branch.addCaseExpression(polyadicExpression); } else if (operands.length == 2) { final PsiExpression lhs = operands[0]; final PsiExpression rhs = operands[1]; if (EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(switchExpression, rhs)) { branch.addCaseExpression(lhs); } else { branch.addCaseExpression(rhs); } } } else if (expression instanceof PsiParenthesizedExpression parenthesizedExpression) { final PsiExpression contents = parenthesizedExpression.getExpression(); extractCaseExpressions(contents, switchExpression, branch); } }