Depth First Tag Browse is hanging

I have Python method for a recursive depth traversal of tags, first mostly copy pasted from an example I found somewhere.

it works on on small amounts of tags, stay less than 50 tags, however I am now trying to run it on a folder that has 60 UDTs in it with 20 UDTs inside each one of those for a total of 3 layers and 1200 ish tags, and it hangs and never completes. I have it set to print each tag so I can watch its progress, so I know it is hanging because it will just stop on a tag and just sit there.

Basically, All I need is a list of all the tags that are nests under a Tag Path / Folder / UDT Instance

Is there a better way to do this that won’t hang? and is faster?

def browseTags(path, filt):
	try:
		results = system.tag.browse(path, filt)
		returnResult = []
		for result in results.getResults():
			# If the item has children, call the function to repeat the process but starting at the child.
			if result['hasChildren'] == True:
				try:
					returnResult.extend(browseTags(result['fullPath'], filt))
				except:
					print("Failed on Path: " + result['fullPath'])
			else:
				print("Tag Found: "+ str(result))
				returnResult.append(result)		
	except:
			print("Failed on Path: " + path)
			print("Result: " + str(results))	
	return returnResult

Not sure the reason for your slow browse, but there is a time out on the browse function to stop it from locking things up. You may have hit it
There's a function similar to that, probably the one you found, on the forums that had a bug in it which is present here, where supplying a filter will actually stop it from traversing any folders, as 9 times out of 10 the filter will filter them out (which is most likely not the intention). The fix is to actually browse twice, one with the filter and one without, where the without filter version will just be used to check for children. Here is an example (there's a bug in it, but your approach using extend mitigates it)