function buildChildList(state, list, p) {
  const mapFn = Array.isArray(list) ? map : mapValues
  return mapFn(list, (val, key) => {
    let getKey = val
    // Handle key: true lists
    if (val === true || p.populateByKey) {
      getKey = key
    }
    // Allow for aliasing populated data see #126 for more details
    const dotRoot = getDotStrPath(p.root)
    const pathArr = [dotRoot, getKey]

    // Handle child param
    if (p.childParam) {
      pathArr.push(p.childParam)
    }

    const pathString = pathArr.join('.')

    // Set to child under key if populate child exists
    if (get(state.data, pathString)) {
      return p.keyProp
        ? { [p.keyProp]: getKey, ...get(state.data, pathString) }
        : get(state.data, pathString)
    }
    // Populate child does not exist
    return val === true || p.populateByKey ? val : getKey
  })
}
@private
@param {object} state - Firebase state object
@param {object} list - Path of parameter to load
@param {object} p - Object with population settings
@returns {object} List of child objects