anchor.diff:                    owner)
               owner)))))
   
  -(export-always 'set-current-owner)
  -(defun set-current-owner (history owner-id)
  -  "Persistently switch owner for HISTORY.
  -OWNER-IDENTIFIER is arbitrary data representing an `owner'.
  -Raise an error when no matching owner exists.
  -See `add-owner' to create an owner.
  -See `with-current-owner' to set the owner locally.
  -See `delete-owner' to remove it from HISTORY."
  -  (if (owner history owner-id)
  -      (setf (slot-value history 'current-owner-id) owner-id)
  -      (error "Owner with identifier ~s does not exist" owner-id)))
  -
  -(export-always 'current-owner)
  -(defun current-owner (history)
  -  (owner history (current-owner-id history)))
  -
  -(export-always 'current-owner-node)
  -(defun current-owner-node (history)
  -  (current (current-owner history)))
  -
  -(export-always 'with-current-owner)
  -(defmacro with-current-owner ((history owner-id) &body body)
  -  "Locally switch owner for HISTORY.
  -See `set-current-owner' to set the owner persistently.
  -OWNER-IDENTIFIER can be any value, even NIL."
  -  (let ((old-owner-id (gensym)))
  -    `(let ((,old-owner-id (current-owner-id ,history)))
  -       (unwind-protect (progn (set-current-owner ,history ,owner-id)
  -                              ,@body)
  -         (set-current-owner ,history ,old-owner-id)))))
  -
  -(defmethod visit ((history history-tree) node)
  -  "Visit NODE with HISTORY's current owner.
  -Return (values HISTORY NODE) so that calls to `visit' can be chained."
  -  (let ((owner (current-owner history)))
  -    (pushnew node (nodes owner))        ; TODO: See TODO note on "fast sets".
  -    (setf (current owner) node)
  -    (let ((binding (gethash owner (bindings node))))
  -      (if binding
  -          (setf (last-access binding) (local-time:now))
  -          (setf (gethash owner (bindings node))
  -                (make-instance 'binding))))
  -    (values history node)))
  +(export-always 'owner-node)
  +(defun owner-node (history owner-spec)
  +  (current (owner history owner-spec)))
  +
  +(defmethod visit ((history history-tree) owner-spec node)
  +  "Visit NODE with HISTORY's OWNER-SPEC.
  +Return (values HISTORY OWNER)."
  +  (let ((owner (owner history owner-spec)))
  +    (when owner
  +      (pushnew node (nodes owner))      ; TODO: See TODO note on "fast sets".
  +      (setf (current owner) node)
  +      (let ((binding (gethash owner (bindings node))))
  +        (if binding
  +            (setf (last-access binding) (local-time:now))
  +            (setf (gethash owner (bindings node))
  +                  (make-instance 'binding)))))
  +    (values history owner)))
   
   (export-always 'visit-all)
  -(defmethod visit-all ((history history-tree) node)
  +(defmethod visit-all ((history history-tree) owner-spec node)
     "Like `visit' but on all nodes between the current node and NODE.
   This is only possible if the current node and NODE are on the same branch.
   If they are not, an error is raised.
  -Return (values HISTORY NODE) so that calls to `visit' can be chained."
  -  (if (eq node (current-owner-node history))
  -      (values history node)
  +Return (values HISTORY OWNER)."
  +  (let ((owner (owner history owner-spec)))
  +    (when (and owner (not (eq node (owner-node history owner-spec))))
         (labels ((nodes-with-common-parent (node current-node-parents)
                    (unless node
  -                   (error "Node ~s and current owner node must be on the same branch" node))
  +                   (error "Node ~s and owner ~s node must be on the same branch" node owner-spec))
                    (if (find node current-node-parents)
                        (list node)
                        (cons node (nodes-with-common-parent (parent node) current-node-parents)))))
  -        (let* ((current-node (current-owner-node history))
  +        (let* ((current-node (owner-node history owner-spec))
                  (current-node-with-parents (cons current-node (all-parents current-node)))
                  (node-parents-until-common-parent (nreverse (nodes-with-common-parent
                                                               node
                                                               current-node-with-parents)))
                  (common-parent (first node-parents-until-common-parent)))
  -          (loop :until (eq common-parent (current-owner-node history))
  -                :do (backward history))
  -          (loop :until (eq node (current-owner-node history))
  +          (loop :until (eq common-parent (owner-node history owner))
  +                :do (backward history owner))
  +          (loop :until (eq node (owner-node history owner))
                   ;; Skip the first node since it's the common-parent and it's already visited.
                   :do (setf node-parents-until-common-parent (rest node-parents-until-common-parent))
  -                :do (go-to-child (data (first node-parents-until-common-parent)) history))
  -          (values history node)))))
  +                :do (go-to-child (data (first node-parents-until-common-parent)) history owner)))))
  +    (values history owner)))
   
   (deftype positive-integer ()
     `(integer 1 ,most-positive-fixnum))
   
   (export-always 'backward)
  -(defmethod backward ((history history-tree) &optional (count 1))
  -  "Go COUNT parent up from the current owner node, if possible.
  -Return (VALUES HISTORY CURRENT-NODE) so that `backward' and `forward' calls can
  -be chained."
  -  (let ((owner (current-owner history)))
  -    (check-type count positive-integer)
  -    (when (parent (current owner))
  +(defmethod backward ((history history-tree) owner-spec &optional (count 1))
  +  "Go COUNT parent up from the OWNER-SPEC current node, if possible.
  +Return (VALUES HISTORY OWNER)."
  +  (check-type count positive-integer)
  +  (let ((owner (owner history owner-spec)))
  +    (when (and owner (parent (current owner)))
         (let ((former-current (current owner)))
  -        (visit history (parent (current owner)))
  +        (visit history owner (parent (current owner)))
           ;; Put former current node back as forward-child if it is not already
           ;; the case, e.g. if current node was set manually.
           (setf (forward-child (current-binding owner))
                 former-current))
         (when (< 1 count)
  -        (backward history (1- count))))
  -    (values history (current owner))))
  +        (backward history owner (1- count))))
  +    (values history owner)))
   
   (export-always 'backward-owned-parents)
  -(defmethod backward-owned-parents ((history history-tree) &optional (count 1))
  -  "Go COUNT parent up from the current owner node, if possible.
  +(defmethod backward-owned-parents ((history history-tree) owner-spec &optional (count 1))
  +  "Go COUNT parent up from the OWNER-SPEC current node, if possible.
   Only contiguous owned parents are considered.
  -Return (VALUES HISTORY CURRENT-NODE) so that `backward' and `forward' calls can
  -be chained."
  -  (let ((owner (current-owner history)))
  -    (when (owned-parent owner (current owner))
  +Return (VALUES HISTORY OWNER)."
  +  (let ((owner (owner history owner-spec)))
  +    (when (and owner (owned-parent owner (current owner)))
         (backward history count))
  -    (values history (current owner))))
  +    (values history owner)))
   
   (export-always 'forward)
  -(defmethod forward ((history history-tree) &optional (count 1))
  -  "Go COUNT forward-children down from the current owner node, if possible.
  +(defmethod forward ((history history-tree) owner-spec &optional (count 1))
  +  "Go COUNT forward-children down from OWNER-SPEC current node, if possible.
   Return (values HISTORY CURRENT-NODE)) so that `backward' and `forward' calls can be
   chained."
     (check-type count positive-integer)
  -  (let ((owner (current-owner history)))
  -    (when (and (current-binding owner)
  +  (let ((owner (owner history owner-spec)))
  +    (when (and owner
  +               (current-binding owner)
                  (forward-child (current-binding owner)))
  -      (visit history (forward-child (current-binding owner)))
  +      (visit history owner (forward-child (current-binding owner)))
         (when (< 1 count)
  -        (forward history (1- count))))
  +        (forward history owner (1- count))))
       (values history (current owner))))
   
   (defun find-entry (history data)
  
positive.code:       (delete-disowned-branch-nodes history nodes))
      (setf (creator-node owner) nil)))
  
  (defun fallback-owner (history)
    "Return an (unspecified) owner ID from HISTORY, or, if there is none,
  add `+default-owner+' to it then return its ID."
    (or (first-hash-table-key (owners history))
        (progn
          (add-owner history +default-owner+)
          +default-owner+)))
  
  (export-always 'delete-owner)
  (declaim (ftype (function (history-tree t) (or null owner)) delete-owner))
  (defun delete-owner (history owner-id)
  
negative.code:         :test #'data-equal-entry-p))
  
  (export-always 'go-to-child)
  (defmethod go-to-child (data (history history-tree) owner-spec &key (child-finder #'find-child)) ; TODO: Should take a node instead?
    "Go to direct current node's child matching DATA.
  Return (values HISTORY OWNER)."
    (let* ((owner (owner history owner-spec))
           (match (when owner (funcall child-finder data owner))))
      (if match
          (visit history owner match)
          (values history owner))))
  
  (export-always 'go-to-owned-child)
  (defmethod go-to-owned-child (data (history history-tree) owner-spec)
    "Go to current node's direct owned child matching DATA.
  A child is owned if it has a binding with OWNER.
  Return (values OWNER (current OWNER))."
    (go-to-child data (owner history owner-spec) :child-finder #'find-owned-child))
  
  
  (defun make-origin-node (history owner-spec data)
    (let* ((owner (owner history owner-spec))
           (new-node (make-node :entry (add-entry history data)
                                :parent (creator-node owner))))
      (when (creator-node owner)
        (push new-node (children (creator-node owner))))
      (setf (origin owner) new-node)
      (visit history owner-spec new-node)))
  
  (export-always 'add-child)
  (defmethod add-child (data (history history-tree) owner-spec)
    "Create or find a node holding DATA and set current node to it.
  Return the (possibly new) current node.
  Return NIL is OWNER-SPEC does not refer to an existing owner.
  
  If current node matches DATA (which may be non-identical since the
  `history-tree''s `key' and `test' functions may identify two non-identical datum
  as equal), do nothing.
  
  If DATA is found among the children, OWNER-SPEC current node `forward-child' is
  set to the matching child, the owner current node is set to this child.
  
  If there is no current node, this creates the `origin' node of OWNER-SPEC
  and also sets `current' to it.  If the owner has a `creator-id' set,
  the new node is added to the children of the current node of the creator."
    (let* ((owner (owner history owner-spec)))
      (when owner
        (cond
          ((null (current owner))
           (make-origin-node history (owner history owner-spec) data))
  
          ((not (data-equal-entry-p data (entry (current owner))))
           (let ((node (find-child data owner)))
             (unless node
               (let ((maybe-new-entry (add-entry history data)))
                 (push (setf node (make-node :entry maybe-new-entry
                                             :parent (current owner)))
                       (children (current owner)))))
             (let ((binding (gethash owner (bindings (current owner)))))
               (setf (forward-child binding) node))
             (forward history owner)))
  
          (t
           ;; Current node matches data, do nothing.
           nil))
  
        (current owner))))
  
  (export 'add-children)
  (defmethod add-children (children-data (history history-tree) owner-spec)
    "Add CHILDREN-DATA to the HISTORY OWNER-SPEC.
  Each child is added with `add-child'.
  Return the (maybe new) current node, which holds the last piece of data in
  `children-data'."
    (let ((owner (owner history owner-spec)))
      (when owner
        (add-child (first children-data) owner)
        (if (rest children-data)
            (add-children (rest children-data) (backward owner))
            (current owner)))))
  
  (export-always 'map-tree)
  (defun map-tree (function tree &key owner flatten include-root
                                   (collect-function #'cons)
                                   (children-function #'children))
    "Map the FUNCTION over the TREE.
  If TREE is a `htree:history-tree', start from its OWNER root.
  If TREE is a `htree:node', start from it.
  OWNER can be an ID or an `owner' object.
  Include results of applying FUNCTION over ROOT if INCLUDE-ROOT is
  non-nil.
  Return results as cons cells tree if FLATTEN is nil and as a flat
  