let bfsearch ~start ~childgen ~goaltest ~combinator =
   (*create a queue to store all the unexpanded nodes*)
   let queue = Queue.create () in
   let rec search start akku () =
      (* test if we have reached a goal *)
      if goaltest start then 
         combinator start true akku
      else
         (* generate all the childs and the path leading up to them *)
         let childs = childgen start in
         let path = combinator start false akku in
         (* Add the partialy evaluated functions to the end of the queue *)
         let rec loop childs =
            match childs with
               child :: childs ->
                  Queue.push (Lazy.lazy_from_fun (search child path)) queue;
                  loop childs
            |  [] -> ()
         in
         loop childs;
         (* get the first function from the queue and evaluate it *)
         if Queue.is_empty queue then None else Lazy.force_val (Queue.pop queue)
   in
   search start None ()