function isModified(modified, path) {
  if (modified[path]) {
    return true;
  }

  // Is any parent path of `path` modified?
  const sp = path.split('.');
  let cur = sp[0];
  for (let i = 1; i < sp.length; ++i) {
    if (modified[cur]) {
      return true;
    }
    cur += '.' + sp[i];
  }

  // Is any child of `path` modified?
  const modifiedKeys = Object.keys(modified);
  if (modifiedKeys.length) {
    const parentPath = path + '.';

    for (const modifiedPath of modifiedKeys) {
      if (modifiedPath.slice(0, path.length + 1) === parentPath) {
        return true;
      }
    }
  }

  return false;
}
Applies defaults to update and findOneAndUpdate operations.

@param {Object} filter
@param {Schema} schema
@param {Object} castedDoc
@param {Object} options
@method setDefaultsOnInsert
@api private