code: function setReference(
      value, root, node, requestedPath, optimizedPath,
      version, expired, lru, comparator, errorSelector, replacedPaths) {
  
      var reference = node.value;
      optimizedPath.splice(0, optimizedPath.length);
      optimizedPath.push.apply(optimizedPath, reference);
  
      if (isExpired(node)) {
          optimizedPath.index = reference.length;
          expireNode(node, expired, lru);
          return [undefined, root];
      }
  
      var container = node;
      var parent = root;
  
      node = node.$_context;
  
      if (node != null) {
          parent = node.$_parent || root;
          optimizedPath.index = reference.length;
      } else {
  
          var index = 0;
          var count = reference.length - 1;
  
          parent = node = root;
  
          do {
              var key = reference[index];
              var branch = index < count;
              optimizedPath.index = index;
  
              var results = setNode(
                  root, parent, node, key, value,
                  branch, true, requestedPath, optimizedPath,
                  version, expired, lru, comparator, errorSelector, replacedPaths
              );
              node = results[0];
              if (isPrimitive(node)) {
                  optimizedPath.index = index;
                  return results;
              }
              parent = results[1];
          } while (index++ < count);
  
          optimizedPath.index = index;
  
          if (container.$_context !== node) {
              createHardlink(container, node);
          }
      }
  
      return [node, parent];
  }
docs: /* eslint-enable