Search all folder in Tag Provider or within another Folder

Hello everybody,

I’m working on a script to get all the folders in a tag provider, and it’s going fine. I’ve prepared a script, but I do not know if there might be any side effects I’m not aware of. So I ask you for your opinion.

def getAllFolder(self, pPath):
        from time import sleep
	if not isinstance(pPath, list):
		pPath = [pPath]
	lFolder = []
	lFolders = [None for _ in pPath]
	for i, folder in enumerate(pPath):
		def search(i=i, folder=folder):
			lFolders[i] = system.tag.browseTags(	parentPath=folder,
											tagPath='*',
											tagType='Folder',
											recursive=False,
											sort='ASC')
		system.util.invokeAsynchronous(search)
	
	# join threads called with system.util.invokeAsynchronous(search)
	while None in lFolders:
		sleep(0.01)
	
	for lf in lFolders:
		for f in lf:
			lFolder.append(f.fullPath)
	
	if len(lFolder) == 0:
		return []
	
	lFolder += self.getAllFolder(lFolder)
	return lFolder

The script is not running on a gateway scope, only client scope.