private static @Nullable PsiField findCheckedField(PsiExpression expression) {
    if (expression instanceof PsiReferenceExpression referenceExpression) {
      final PsiElement target = referenceExpression.resolve();
      if (!(target instanceof PsiField)) {
        return null;
      }
      return (PsiField)target;
    }
    else if (expression instanceof PsiBinaryExpression binaryExpression) {
      final IElementType tokenType = binaryExpression.getOperationTokenType();
      if (!ComparisonUtils.isComparisonOperation(tokenType)) {
        return null;
      }
      final PsiExpression lhs = binaryExpression.getLOperand();
      final PsiExpression rhs = binaryExpression.getROperand();
      final PsiField field = findCheckedField(lhs);
      if (field != null) {
        return field;
      }
      return findCheckedField(rhs);
    }
    else if (expression instanceof PsiPrefixExpression prefixExpression) {
      final IElementType tokenType =
        prefixExpression.getOperationTokenType();
      if (!JavaTokenType.EXCL.equals(tokenType)) {
        return null;
      }
      return findCheckedField(prefixExpression.getOperand());
    }
    else {
      return null;
    }
  }
private static @Nullable PsiField findCheckedField(PsiExpression expression)