let relation_of_filename path1 path2 =
    let rec relation_of_filename_aux path1 path2 =
      match (path1,path2) with
        ([], []) ->
        Equal
      | (hd1 :: tl1, hd2 :: tl2) ->
        if hd1 = hd2 then
          relation_of_filename_aux tl1 tl2
        else
        begin
          NoRelation (String.compare 
              (string_of_filename [hd1]) 
              (string_of_filename [hd2])
            )
        end
      | (subdir, []) ->
        SubDir
      | ([], updir) ->
        UpDir
    in
    relation_of_filename_aux (reduce path1) (reduce path2)