function promisesForPopulate(
  firebase,
  dataKey,
  originalData,
  populatesIn
) {
  // TODO: Handle selecting of parameter to populate with (i.e. displayName of users/user)
  const promisesArray = []
  const results = {}

  // test if data is a single object, try generating populates and looking for the child
  const populatesForData = getPopulateObjs(
    typeof populatesIn === 'function'
      ? populatesIn(dataKey, originalData)
      : populatesIn
  )

  const dataHasPopulateChilds = some(populatesForData, (populate) =>
    has(originalData, populate.child)
  )

  if (dataHasPopulateChilds) {
    // Data is a single object, resolve populates directly
    forEach(populatesForData, (p) => {
      if (isString(get(originalData, p.child))) {
        return promisesArray.push(
          getPopulateChild(firebase, p, get(originalData, p.child)).then(
            (v) => {
              // write child to result object under root name if it is found
              if (v) {
                set(results, `${p.root}.${get(originalData, p.child)}`, v)
              }
            }
          )
        )
      }

      // Single Parameter is list
      return promisesArray.push(
        populateList(firebase, get(originalData, p.child), p, results)
      )
    })
  } else {
    // Data is a list of objects, each value has parameters to be populated
    // { '1': {someobject}, '2': {someobject} }
    forEach(originalData, (d, key) => {
      // generate populates for this data item if a fn was passed
      const populatesForDataItem = getPopulateObj(
        typeof populatesIn === 'function' ? populatesIn(key, d) : populatesIn
      )

      // resolve each populate for this data item
      forEach(populatesForDataItem, (p) => {
        // get value of parameter to be populated (key or list of keys)
        const idOrList = get(d, p.child)

        // Parameter/child of list item does not exist
        if (!idOrList) {
          return
        }

        // Parameter of each list item is single ID
        if (isString(idOrList)) {
          return promisesArray.push(
            getPopulateChild(firebase, p, idOrList).then((v) => {
              // write child to result object under root name if it is found
              if (v) {
                set(results, `${p.root}.${idOrList}`, v)
              }
              return results
            })
          )
        }

        // Parameter of each list item is a list of ids
        if (Array.isArray(idOrList) || isObject(idOrList)) {
          // Create single promise that includes a promise for each child
          return promisesArray.push(
            populateList(firebase, idOrList, p, results)
          )
        }
      })
    })
  }

  // Return original data after population promises run
  return Promise.all(promisesArray).then(() => results)
}
@private
@param {object} firebase - Internal firebase object
@param {string} dataKey - Object to have parameter populated
@param {object} originalData - Data before population
@param {Function|object} populatesIn - Populate configs or function returning configs
@returns {Promise} Promise which resolves after populate data is loaded