code: public function rebuildBounds($node, $depth = 0) {
      $k = $this->scopedKey($node);
  
      $node->setAttribute($node->getLeftColumnName(), $this->getNextBound($k));
      $node->setAttribute($node->getDepthColumnName(), $depth);
  
      foreach($this->children($node) as $child)
        $this->rebuildBounds($child, $depth + 1);
  
      $node->setAttribute($node->getRightColumnName(), $this->getNextBound($k));
  
      $node->save();
    }
docs: Recompute left and right index bounds for the specified node and its
  children (recursive call). Fill the depth column too.