(* Turn a code into a tree *) 
Definition pbbuild (l : code A) : pbtree :=
  fold_right (fun a c => pbadd (fst a) c (snd a)) (pbleaf empty) l.

Theorem all_pbleaves_pbbuild : forall c, c <> nil -> unique_prefix c -> permutation (map (fst (B:=_)) c) (all_pbleaves (pbbuild c)).