anchor.diff:  (deftype positive-integer ()
     `(integer 1 ,most-positive-fixnum))
   
  -(deftype non-negative-integer ()        ; TODO: Remove if unused.
  +(deftype non-negative-integer ()
     `(integer 0 ,most-positive-fixnum))
   
  -
  -
  -(eval-when (:compile-toplevel :load-toplevel :execute)
  -  (export 'back))
  -;; TODO: Can we set ftype for methods return value?
  -;; (declaim (ftype (function (history-tree &optional positive-integer))
  -;;                 back))
  +(export-always 'back)
  +(defmethod back ((owner owner) &optional (count 1))
  +  "Go COUNT parent up from the current OWNER node.
  +Return (values OWNER (current OWNER)) so that `back' and `forward' calls can
  +be chained."
  +  (check-type count 'positive-integer)
  +  (when (and (current owner)
  +             (parent (current history)))
  +    (let ((former-current (current owner)))
  +      (visit 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)
  +      (back owner (1- count))))
  +  (values owner (current owner)))
  +
   (defmethod back ((history history-tree) &optional (count 1))
  -  "Go COUNT parent up from the current node.
  -Return (VALUES HISTORY (CURRENT HISTORY)) so that `back' and `forward' calls can
  +  "Go COUNT parent up from the current owner node.
  +Return (VALUES HISTORY CURRENT-NODE) so that `back' and `forward' calls can
   be chained."
  -  (when (and (current history)
  -             (parent (current history)))
  -    ;; Put former current node back in first position if it is not already
  -    ;; there, e.g. if current node was set manually.
  -    (let ((former-current (current history)))
  -      (setf (current history) (parent (current history)))
  -      (setf (children (current history))
  -            (cons former-current
  -                  (delete former-current (children (current history))))))
  +  (when (current-owner history)
  +    (values history (nth-value 1 (back (current-owner history) count)))))
  +
  +(export-always 'forward)
  +(defmethod forward ((owner owner) &optional (count 1))
  +  "Go COUNT first-children down from the current OWNER node.
  +Return (values OWNER (CURRENT OWNER)) so that `back', `forward' and
  +`go-to-child' calls can be chained."
  +  (check-type count 'positive-integer)
  +  (when (and (current owner)
  +             (children (current owner)))
  +    (visit (forward-child (current-binding owner)))
       (when (< 1 count)
  -      (back history (1- count))))
  -  (values history (current history)))
  -
  -(eval-when (:compile-toplevel :load-toplevel :execute)
  -  (export 'forward))
  -;; (declaim (ftype (function (history-tree &optional positive-integer))
  -;;                 forward))
  +      (forward owner (1- count))))
  +  (values owner (current owner)))
  +
   (defmethod forward ((history history-tree) &optional (count 1))
  -  "Go COUNT first-children down from the current node.
  -Return (VALUES HISTORY (CURRENT HISTORY)) so that `back', `forward', and
  +  "Go COUNT first-children down from the current owner node.
  +Return (values HISTORY CURRENT-NODE)) so that `back', `forward', and
   `go-to-child' calls can be chained."
  -  (when (and (current history)
  -             (children (current history)))
  -    (setf (current history) (first (children (current history))))
  -    (when (< 1 count)
  -      (forward history (1- count))))
  -  (values history (current history)))
  +  (when (current-owner history)
  +    (values history (nth-value 1) (forward (current-owner history) count))))
   
   
   
  
positive.code:                        (children (current history))))
        matching-node)))
  
  (eval-when (:compile-toplevel :load-toplevel :execute)
    (export 'add-child))
  (defmethod add-child (data (history history-tree) &key (test #'equal))
    "Create or find a node holding DATA and set current node to it.
  Return (possibly new) current node.
  
  If current node matches DATA (according to TEST), then we update its data to
  DATA (since the TEST function does not necessarily mean the data is identical).
  
  If DATA is found among the children (according to TEST), the child is moved
  first among the children, its data is set to DATA and the current node is set to
  this child.
  
  If there is no current element, this creates the first element of the tree."
    (cond
      ((null (current history))
       (let ((new-node (make-node :data data)))
         (setf (root history) new-node)
         (setf (current history) (root history))))
      ((not (funcall test data (data (current history))))
       (let ((node (delete-child data history :test test)))
         (push (or (when node
                     (setf (data node) data)
                     node)
                   (make-node :data data :parent (current history)))
               (children (current history)))
         (forward history)))
      (t
       (setf (data (current history)) data)))
    (current history))
  
  (eval-when (:compile-toplevel :load-toplevel :execute)
    (export 'add-children))
  
negative.code: ;;;; SPDX-License-Identifier: BSD-3-Clause
  
  (in-package :history-tree)
  
  ;; TODO: Unexport most (all?) slot writers.
  
  (defmacro export-always (symbols &optional (package nil package-supplied?)) ; From serapeum.
    "Like `export', but also evaluated at compile time."
    `(eval-when (:compile-toplevel :load-toplevel :execute)
       (export ,symbols ,@(and package-supplied? (list package)))))
  
  (define-class node ()
    ((parent nil
  