code: function setValue(obj = {}, path, value) {
    const keys = path.split('.');
    const used = [];
    while (keys.length > 1) {
      const key = keys.shift();
      used.push(key);
      if (!(key in obj)) {
        obj[key] = {};
      } else if (!isValid(obj[key])) {
        throw new Error(`path ${used.join('.')} is set to a primative value`);
      }
      obj = obj[key];
    }
    obj[keys[0]] = value;
    return obj;
  }
docs: --- setValue