It’s a messy process. You would need a map of type
Primitive component object reference: StructA
Where StructA is an array of material interface object references
That way you can easily look the component up in the map, and automatically get the list of materials.
Why do you need to do this, btw?