This was a homework problem. What was the name of the function, mystery?
(define (mystery l)
   (cond ((null? l) ())
         ((list? (car l)) (append (mystery (car l))
                                  (mystery (cdr l))))
         (else (cons (car l) (mystery (cdr l))))))