Correction and small refactoring.
Handle the case where two pathes only differs at a tail concisting of slashes.