lib/mongoose-hidden.js
function pathsFromTree(obj, parentPath) {
  if (Array.isArray(obj)) {
    return parentPath
  }
  if (typeof obj === 'object' && obj.constructor.name === 'VirtualType') {
    return obj.path
  }

  if (obj.constructor.name === 'Schema') {
    obj = obj.tree
  }

  return Object.keys(obj).reduce((paths, key) => {
    if (typeof obj[key] !== 'object' || typeof obj[key].type !== 'undefined') {
      paths.push(joinKey(parentPath, key))
      return paths
    }
    return [].concat(paths, pathsFromTree(obj[key], joinKey(parentPath, key)))
  }, [])
}
function pathsFromTree(obj, parentPath) {
  if (Array.isArray(obj)) {
    return parentPath
  }
  if (typeof obj === 'object' && obj.constructor.name === 'VirtualType') {
    return obj.path
  }

  if (obj.constructor.name === 'Schema') {
    obj = obj.tree
  }

  return Object.keys(obj).reduce((paths, key) => {
    if (typeof obj[key] !== 'object' || typeof obj[key].type !== 'undefined') {
      paths.push(joinKey(parentPath, key))
      return paths
    }
    return [].concat(paths, pathsFromTree(obj[key], joinKey(parentPath, key)))
  }, [])
}
function pathsFromTree ( obj , parentPath ) { if ( Array . isArray ( obj ) ) { return parentPath } if ( typeof obj === 'object' && obj . constructor . name === 'VirtualType' ) { return obj . path } if ( obj . constructor . name === 'Schema' ) { obj = obj . tree } return Object . keys ( obj ) . reduce ( ( paths , key ) => { if ( typeof obj [ key ] !== 'object' || typeof obj [ key ] . type !== 'undefined' ) { paths . push ( joinKey ( parentPath , key ) ) return paths } return [ ] . concat ( paths , pathsFromTree ( obj [ key ] , joinKey ( parentPath , key ) ) ) } , [ ] ) }
Builds a list of paths based on the schema tree. This includes virtuals and nested objects as well

@access private
@param {object} obj the root object
@param {string} parentPath the path taken to get to here
@returns {array} an array of paths from all children of the root object
Builds a list of paths based on the schema tree . This includes virtuals and nested objects as well