function _isManuallyPopulatedArray(val, ref) {
  if (!Array.isArray(val)) {
    return false;
  }
  if (val.length === 0) {
    return false;
  }

  for (const el of val) {
    if (!(el instanceof Document)) {
      return false;
    }
    const modelName = el.constructor.modelName;
    if (modelName == null) {
      return false;
    }
    if (el.constructor.modelName != ref && el.constructor.baseModelName != ref) {
      return false;
    }
  }

  return true;
}
Alias for `set()`, used internally to avoid conflicts

@param {String|Object} path path or object of key/vals to set
@param {Any} val the value to set
@param {Schema|String|Number|Buffer|*} [type] optionally specify a type for "on-the-fly" attributes
@param {Object} [options] optionally specify options that modify the behavior of the set
@param {Boolean} [options.merge=false] if true, setting a [nested path](https://mongoosejs.com/docs/subdocs.html#subdocuments-versus-nested-paths) will merge existing values rather than overwrite the whole object. So `doc.set('nested', { a: 1, b: 2 })` becomes `doc.set('nested.a', 1); doc.set('nested.b', 2);`
@return {Document} this
@method $set
@memberOf Document
@instance
@api public