Identify parts on their index within their parent element

Hi there,

in order to do a quality control on an existing project, I would like to assign a parameter to a part, based on a parameter in the parent element, which expresses the index in the layer structure.

How do I match the part with the corresponding value in the parent element, based on the position (index) within the layer structure?

Please keep in mind that the parameters in the parent family are instance parameters, I already have a script to give the part the material code from the layer structure, but that is not useful in this case.

Kind regards,

Willem