Getting/setting layered material parameters using python

hi there,
I am pretty new to scripting the editor (and unreal in general). Hopefully this is a quick question someone can help me with.

I am trying to get/set a number of different parameters on a layered material instance using python (change color, swap textures, etc). The issue is that the instance shares a number of material layers and blends, so if I list the instance’s texture parameters by name, I get a huge number of duplicates and cant tell which layer they are from.

How can I get/set these with respect to the layer they are in?