static boolean hasReferenceToVariable(@NotNull PsiVariable variable, @Nullable PsiElement element, @NotNull BuilderType type) {
    if (element instanceof PsiReferenceExpression referenceExpression) {
      return referenceExpression.isReferenceTo(variable);
    }
    else if (element instanceof PsiParenthesizedExpression parenthesizedExpression) {
      final PsiExpression expression = parenthesizedExpression.getExpression();
      return hasReferenceToVariable(variable, expression, type);
    }
    else if (element instanceof PsiMethodCallExpression methodCallExpression) {
      final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
      final String name = methodExpression.getReferenceName();
      if (name != null && returnSelfNames.get(type).contains(name)) {
        return hasReferenceToVariable(variable, methodExpression.getQualifierExpression(), type);
      }
    }
    else if (element instanceof PsiConditionalExpression conditionalExpression) {
      final PsiExpression thenExpression = conditionalExpression.getThenExpression();
      if (hasReferenceToVariable(variable, thenExpression, type)) {
        return true;
      }
      final PsiExpression elseExpression = conditionalExpression.getElseExpression();
      return hasReferenceToVariable(variable, elseExpression, type);
    }
    return false;
  }
static boolean hasReferenceToVariable(@NotNull PsiVariable variable, @Nullable PsiElement element, @NotNull BuilderType type)