function flatten(result, prefix, obj, seen) {
  seen = seen || []
  seen.push(obj)

  for (const key in obj) {
    if (seen.indexOf(obj[key]) > -1) {
      continue
    }

    if (obj[key] instanceof Object) {
      flatten(result, prefix + key + '.', obj[key], seen)
    } else {
      result[prefix + key] = obj[key]
    }
  }

  return result
}
Flatten nested maps of JSONifiable data.

Ex: {a: 5, b: {c: true, d: 7}} -> {a: 5, 'b.c': true, 'b.d': 7}

@private
@param {object} result Object to place key-value pairs into, normally called with `{}`.
@param {string} prefix Prefix for keys, normally called with `''`.
@param seen
@param {object} obj    Object to be flattened.
@returns {object} Object with flattened key-value pairs