Yes - that did the trick:
// don't scan received local shares, these can be scanned when scanning the owner's storage
if ($storage->instanceOfStorage(SharedStorage::class)
|| $storage->instanceOfStorage(CollectiveStorage::class)
) {
continue;
}
I will create a GitHub issue and PR for that as soon as possible. Thanks for your help.
The GitHub issue including a Pull Request for the workaround can be found here: [Bug]: Shared Collectives cause "Path not found" when scannig files with "occ files:scan --all" · Issue #42496 · nextcloud/server · GitHub