(define (tree-mean tree)
  (define res cons)
  (define totale-som car)
  (define aantal cdr)
  (cond ((null? tree) (res 0 0))
        ((atom? tree) (res tree 1))
        (else (let ((res-car (tree-mean (car tree)))
                    (res-cdr (tree-mean (cdr tree))))
                (/ (+ (totale-som res-car) (totale-som res-cdr))
                   (+ (aantal res-car) (aantal res-cdr)))))))