I don't know how to get the complete assembly, including hinges, etc

I am creating a mechanism to connect trains together. (I am using rigid constraints for the connecting mechanism.)
I am trying to recognize the connected cars as a single assembly and set the network owner of all its parts to the driver.
I searched the forum and found out about GetJoints() and GetConnectedParts().
I have tried these, but GetJoints() only returns constraints and GetConnectedParts() does not include parts connected by hinge constraints in the assembly.
My current thought is to use GetJoints() on the train coupling and get all the parts of the other car in a for loop, but this doesn’t seem very smart.
Please let me know if there is any other better technique.