Bug in NodePath::getChild()?

Try replacing the loop by:

i=0
while i < render.getNumChildren():
    child = render.getChild(i)
    i = i + 1
    ...

I bet you won’t get that error but you may get another from a side effect on your code inside the loop that changes the element count of the render node.