(define (avl-tree-traverse origin stack key cont) (let loop ((parent '() ) (child origin) ) (if (null? child) (cont stack parent child) (let ((child-key (avl-node-key child) ) (loop-helper (lambda (subtree) (if (not (null? parent) ) (avl-stack-push! stack (cons parent subtree) ) ) (loop child (avl-node-subtree child subtree) ) ) ) ) (cond ((< key child-key) (loop-helper *l-subtree*) ) ((> key child-key) (loop-helper *r-subtree*) ) (else (cont stack parent child) ) ) ) ) ) )