indexForNode() is expensive, so only call it if really needed.

In case of the majority of the scene graph not having changed this
increases the frame rate on CPU-constrained embedded device by 30-50%.