code: function collectAssignmentsInto(
    assignments: Array<{path: Array<string | number>, value: mixed}>,
    parentPath: Array<string | number>,
    parentValue: Object,
  ): void {
    // Iterate over the entries in the array or object.
    forEach(parentValue, (value, key) => {
      // The "path" is the sequence of keys to arrive at this assignment.
      const path = parentPath.concat(key);
      // For each entry, either add an assignment or recurse.
      if (typeof value === 'object' && value !== null) {
        collectAssignmentsInto(assignments, path, value);
      } else {
        assignments.push({path, value});
      }
    });
  }
docs: Recursively collect assignments