3 (defun extreme-node-with-path (root leftp &optional path)
4 (do ((node root (if leftp (left node) (right node)))
6 ((null node) (values parent path))
9 (defun make-iterator (tree &key
11 (current nil currentp)
13 (declare (type binary-tree tree))
14 (let ((modcount (modcount tree)))
15 (multiple-value-bind (current stack)
16 (if (and currentp stackp)
17 (values current stack)
18 (extreme-node-with-path (root tree) forwardp))
21 ((/= modcount (modcount tree))
22 (error "~A modified during iteration" tree))
28 (node (if forwardp (right top) (left top))))
31 (setf current (first stack)))
33 (setf (values current stack)
34 (extreme-node-with-path node forwardp stack))))
35 (values next t))))))))