Ah, sorry. You need to convert the list into something which Python can iterate. I’m more a Java developer and thus not really used to these specialities when using snappy.
So replace
nodes = result.getRasterDataNodes()
by
nodes = list(product.getRasterDataNodes().toArray())
Instead of using an empty string you could also do
n.setValidPixelExpression(None)
The complete updated script:
nodes = list(product.getRasterDataNodes().toArray())
for n in nodes:
n.setValidPixelExpression(None)