CompareToResult (PsiBinaryExpression binaryExpression) { if (binaryExpression == null) { return null; } final IElementType tokenType = binaryExpression.getOperationTokenType(); if (!JavaTokenType.NE.equals(tokenType) && !JavaTokenType.EQEQ.equals(tokenType)) { return null; } PsiMethodCallExpression compareToExpression; final PsiExpression lhs = PsiUtil.skipParenthesizedExprDown(binaryExpression.getLOperand()); final PsiExpression rhs = PsiUtil.skipParenthesizedExprDown(binaryExpression.getROperand()); if (lhs instanceof PsiMethodCallExpression) { compareToExpression = (PsiMethodCallExpression)lhs; if (!MethodCallUtils.isCompareToCall(compareToExpression) || !ExpressionUtils.isZero(rhs)) { return null; } } else if (rhs instanceof PsiMethodCallExpression) { compareToExpression = (PsiMethodCallExpression)rhs; if (!ExpressionUtils.isZero(lhs) || !MethodCallUtils.isCompareToCall(compareToExpression)) { return null; } } else { return null; } return new CompareToResult(binaryExpression, compareToExpression); }