function populateChild(state, child, p) {
  // no matching child parameter
  const childVal = get(child, p.child)
  if (!child || !childVal) {
    return null
  }
  // populate child is key
  if (typeof childVal === 'string' || childVal instanceof String) {
    // attach child paramter if it exists
    const dotRoot = (p.storeAs ? p.storeAs : p.root)
      .split('/')
      .filter(Boolean) // Drop falsey values (compact)
      .join('.')
    const pathArr = [dotRoot, childVal]

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

    const pathString = pathArr.join('.')

    const populateVal = get(state.data, pathString)
    if (populateVal) {
      return set(
        {},
        p.childAlias || p.child,
        p.keyProp ? { [p.keyProp]: childVal, ...populateVal } : populateVal
      )
    }
    // matching child does not exist
    return child
  }
  // populate child list
  return set({}, p.childAlias || p.child, buildChildList(state, childVal, p))
}
@private
@param {object} state - Firebase state object
@param {object} child - Path of parameter to load
@param {object} p - Object with population settings
@returns {object} Populated child object