I'm afraid this will decide that the longest common prefix of `/foo/bar` and `/foo/barbaz` is `/foo/bar`, which is not what we want: `/foo`. I think you can't work on Strings but on path element sequence.