let parts filename =
let rec loop acc filename =
match split filename with
| "." as base, "." -> base :: acc
| "/" as base, "/" -> base :: acc
| rest, dir ->
loop (dir :: acc) rest
in
loop [] filename