@TracyLove I'm a real python newb, so don't quote me on this (and apologies if it's wrong!).
I would think to get the layers nested in groups inside of groups you'd need to add another for loop to the last line of code
so instead of
# throw sub-layers from groups into lyrs list
[lyrs.append(k) for l in grp_lyrs for k in l.layers]
which I rewrote to make sense in my brain as (sorry can't figure out how to insert code in a reply):
for l in grp_lyrs:
for k in l.layers:
lyrs.append(k)
It might need to be something like:
for l in grp.layers: # accessing the group layers as group layers individually
for k in l.layers: # accessing the sub-group layers individually (which in your case are still group layers?)
for j in k.layers: # now hopefully accessing the sub-sub-layers you mentioned
lyrs.append(j) # appends the list of sub-sub-layers to the first of all non-group layers
which could maybe be prettier as:
[lyrs.append(j) for l in grp.layers for k in l.layers for j in k.layers]
That being said, I'm finding not all my "I would think"s based on R translate correctly into Python, but hopefully this helps gets you closer (if you're still working on it)! I share your frustration with the documentation for certain things. I often feel like it's for people who already understand what's going on (to which I don't belong, but aspire to!).