I don't think so. We need to update the whole tree from the original path (internalPath). Imagine following situation:

user has ```/folder1/folder2/folder3``` and shares  ```folder3``` with user2. For user2 this will look like ```/Shared/folder3``` and that's also the path we will receive here. dirname() from ```$path``` would return ```Shared``` but we want to iterate over  ```/folder1/folder2/folder3``` to update the original path that's why we need to iterate  over the internalPath which is the correct  ```/folder1/folder2/folder3```