> Later (l. 367) you do query_layers = layer.queryLayers if layer.queryLayers else l['wmsLayers'], I think that enough (and better).

You're absolutely right. I'll remove the line. Very good catch!