Change ParentDirectory extension method to handle a case with the given ...

...path ends with a directory separator character