localeMutator = function (locale, singular, allowBranching) {
    // Bail out on non-existent locales to defend against internal errors.
    if (!locales[locale]) return Function.prototype

    // Handle object lookup notation
    const indexOfDot = objectNotation && singular.lastIndexOf(objectNotation)
    if (objectNotation && indexOfDot > 0 && indexOfDot < singular.length - 1) {
      // If branching wasn't specifically allowed, disable it.
      if (typeof allowBranching === 'undefined') allowBranching = false
      // This will become the function we want to return.
      let accessor = null
      // An accessor that takes one argument and returns null.
      const nullAccessor = () => null
      // Fix object path.
      let fixObject = () => ({})
      // Are we going to need to re-traverse the tree when the mutator is invoked?
      let reTraverse = false
      // Split the provided term and run the callback for each subterm.
      singular.split(objectNotation).reduce((object, index) => {
        // Make the mutator do nothing.
        accessor = nullAccessor
        // If our current target object (in the locale tree) doesn't exist or
        // it doesn't have the next subterm as a member...
        if (
          object === null ||
          !Object.prototype.hasOwnProperty.call(object, index)
        ) {
          // ...check if we're allowed to create new branches.
          if (allowBranching) {
            // Fix `object` if `object` is not Object.
            if (object === null || typeof object !== 'object') {
              object = fixObject()
            }
            // If we are allowed to, create a new object along the path.
            object[index] = {}
          } else {
            // If we aren't allowed, remember that we need to re-traverse later on and...
            reTraverse = true
            // ...return null to make the next iteration bail our early on.
            return null
          }
        }
        // Generate a mutator for the current level.
        accessor = (value) => {
          object[index] = value
          return value
        }
        // Generate a fixer for the current level.
        fixObject = () => {
          object[index] = {}
          return object[index]
        }

        // Return a reference to the next deeper level in the locale tree.
        return object[index]
      }, locales[locale])

      // Return the final mutator.
      return (value) => {
        // If we need to re-traverse the tree
        // invoke the search again, but allow branching
        // this time (because here the mutator is being invoked)
        // otherwise, just change the value directly.
        value = missingKeyFn(locale, value)
        return reTraverse
          ? localeMutator(locale, singular, true)(value)
          : accessor(value)
      }
    } else {
      // No object notation, just return a mutator that performs array lookup and changes the value.
      return (value) => {
        value = missingKeyFn(locale, value)
        locales[locale][singular] = value
        return value
      }
    }
  }
Allows delayed mutation of a translation nested inside objects.
@description Construction of the mutator will attempt to locate the requested term
inside the object, but if part of the branch does not exist yet, it will not be
created until the mutator is actually invoked. At that point, re-traversal of the
tree is performed and missing parts along the branch will be created.
@param {String} locale The locale to use.
@param {String} singular The singular term to look up.
@param [Boolean} [allowBranching=false] Is the mutator allowed to create previously
non-existent branches along the requested locale path?
@returns {Function} A function that takes one argument. When the function is
invoked, the targeted translation term will be set to the given value inside the locale table.