No clear idea here, there may be a way to utilize flow rate or a similar parameter which is simple. I’m not an expert on the MEP side. Perhaps @T_Pover has an idea?
One other possibility: utilize shortest walk.
Idea would be to get the location line of all duct systems in a view, build a connected network via some fancy polyline operations, find ‘endpoints’ where the network only extends in one direction, and then do a shortest walk from each endpoint member to the origin point. Search the walk networks for common items - those are your mains - and revert back to the duct elements. The drawback with this is the method may tax your system a good bit, the extent of which I am not sure of. I’m also not sure of how to find the start point beyond size (pretty sure the largest of the singlely connected ducts would work, but again, no expert here).