Find VAV that Serves HVAC Space and Assign Tag to Space Parameter

I want to determine which VAV serves a Revit space and assign the terminal unit tag (TU TAG assigned) to a space parameter. The VAV’s are associated with spaces through “Duct Systems” (supply ductwork and air terminals). I realize that HVAC zoning exists for this purpose, but that will not work for my situation.

Current Dynamo Solution:
-Get all air terminals and the space that they serve
-Associate the air terminals to an HVAC system and thus the mechanical equipment (VAV) that services the air terminal
-Use this to assign the TU TAG (assigned) tag to a space parameter of the same name

I have a Dynamo script that “works” but it’s very basic and more often than not, it produces errors. Any help in cleaning up the script would be appreciated.

SystemNametoSpace.dyn (98.5 KB)