I'm not too sure about the mixture of dict() and not. Would be better to stick to one or the other, especially inside this kinda construct. IMHO!

I also wonder whether we should start flattening this if we go above a certain level? Or maybe flatter by accordion?