boolean (@Nullable PsiExpression first, @Nullable PsiExpression second) { if(first == null && second == null) return true; if(first == null || second == null) return false; PsiMethodCallExpression firstCall = tryCast(first, PsiMethodCallExpression.class); PsiMethodCallExpression secondCall = tryCast(second, PsiMethodCallExpression.class); PsiExpression firstCurrent = first; PsiExpression secondCurrent = second; while (firstCall != null && secondCall != null) { String firstName = firstCall.getMethodExpression().getReferenceName(); String secondName = secondCall.getMethodExpression().getReferenceName(); if(firstName == null || !firstName.equals(secondName)) return false; firstCurrent = firstCall.getMethodExpression().getQualifierExpression(); secondCurrent = secondCall.getMethodExpression().getQualifierExpression(); firstCall = tryCast(firstCurrent, PsiMethodCallExpression.class); secondCall = tryCast(secondCurrent, PsiMethodCallExpression.class); } return firstCurrent == null && secondCurrent == null || EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(firstCurrent, secondCurrent); }