Definition refineList (d : SplitDirection) (l : list SplitPath) : list SplitPath :=
  map (@tl SplitDirection) (filter (fun p => match hd_error p with
                             | Some d' => eq_dir_b d d'
                             | _       => false
                           end) l).

(* Specifications: *)
Lemma refineCorrect : forall d l p, In p (refineList d l) -> In (d :: p) l.
Lemma refineCorrect' : forall d l p, In (d :: p) l -> In p (refineList d l).
Lemma refinePreservesPrefixFree : forall d l, PrefixFree l -> PrefixFree (refineList d l).