If you leave it too long before updating, (e.g. 500,000 leaves), and then call `update`, JS returns a stack too deep error. We can break the updating into small 'chunks' of leaves, so as to avoid this error.