How to get all Assemblies of a Mechanism

How do I best get all Assemblies of a Mechanism, so I can set their Assembly properties with the new physics API such as AssemblyLinearVelocity? Example: Snake with hinges to form segmentations; mechanism: change the AssemblyVelocities of each segment.

https://developer.roblox.com/en-us/api-reference/function/BasePart/GetConnectedParts
is something of a part:GetMyAssemblyParts.

My current best solution is to take a table of all parts in the snake model, run this on the first Part, subtract all returned, and repeat until model cleared and X amount of assemblies in the mechanism returned.