How to get tagged files for all users?

coding
9.1.x

#1

Hello. Not about oc-app, but seems to be related.

I trying to write a script to backup all files marked by any user with a specific tag. Excerpt:

$bktag = $argv[1];
require_once OCROOT.'/lib/base.php';
OC_App::loadApps();
$config = \OC::$server->getConfig();
$bktagid = \OC::$server
                ->getSystemTagManager()
                ->getTag($bktag, TRUE, TRUE)
                ->getId();
$ids = \OC::$server
                ->getSystemTagObjectMapper()
                ->getObjectIdsForTags($bktagid, 'files');

This far everything is ok, $ids contains some numbers.
Now I need to get filesystem paths for each id. Trying

$rootFolder = \OC::$server->getRootFolder();
foreach($ids as $id){
                $node = $rootFolder->getById($id); // Not working!
}

So main question is: Is there a way to translate $ids to filesystem paths without calling getUserFolder() for each owncloud user?

BTW, adding "$rootFolder->getUserFolder("some_ldap_user");" before "foreach" seems to make getById() return nodes not only owned by "some_ldap_user", but sometimes owned by another users too. Not an issue when using a non-ldap user in my case. Looks like a bug for me.