title: get pairs out of a huffman tree
body: <p>I'm trying to write a procedure Huffman-leaves; the procedure returns a list of pairs from a created huffman tree.
  Example on how it runs</p>
  
  <pre><code>  (huffman-leaves sample-tree) 
     -&gt;((A . 8) (C . 5) (B . 1) (D . 1))
  </code></pre>
  
  <p>What I've comed up with but got writers block...</p>
  
  <pre><code>(define (huffman-leaves tree)
    (define (huffman-get-pairs current-branch pairs)
       (if (or (null? tree) (null? current-branch))
           pairs
           (let ((next-branch
                  (get-branch (car current-branch) current-branch)))
             (not (member? next-branch pairs)
                  (if (leaf? next-branch)
                      (cons (append  pairs next-branch)
                            (display pairs)
                            (huffman-get-pairs (cadr current-branch) pairs))
                      (huffman-get-pairs next-branch pairs))))))
    (huffman-get-pairs tree '()))
  
    (member? item 'list) #if item in list return #t else #false
  </code></pre>
  
  <p>I know that I'm doing something wrong but I can't see it.
  How can I stop a search in a huffman-tree in scheme? Any tip that I should be doing different?</p>