Template

The follow-directions function's arguments are both interesting from the point of view of the template. So, rather than just having two conditions from a binary tree or three conditions from the path, we have 6 conditions, one for each combination of family trees and paths:

(define (bt-path-template a-bt a-path)
  (cond
    [(and (boolean? a-bt)
          (null? a-path))
     ...]
    [(and (bt? a-bt)
          (null? path))
     ...]
    [(and (boolean? a-bt)
          (eq? 'l (car path)))
     ...]
    [(and (bt? a-bt)
          (eq? 'l (car path)))
     ...]
    [(and (boolean? a-bt)
          (eq? 'r (car path)))
     ...]
    [(and (bt? a-bt)
          (eq? 'r (car path)))
     ...]))