public function rebuild()
{
// Rebuild lefts and rights for each root node and its children (recursively).
// We go by setting left (and keep track of the current left bound), then
// search for each children and recursively set the left index (while
// incrementing that index). When going back up the recursive chain we start
// setting the right indexes and saving the nodes...
$self = $this;
$this->node->getConnection()->transaction(function () use($self) {
foreach ($self->roots() as $root) {
$self->rebuildBounds($root, 0);
}
});
}