code: public function getTotalSize()
      {
          if (!isset($this->_size)) {
              $size = $this->getSize();
              if (!$this->isLeaf()) {
                  foreach ($this->getChildren() as $child) {
                      $size += $child->getTotalSize();
                  }
              }
              $this->_size = $size;
          }
  
          return $this->_size;
      }
docs: depth first search to get the total number of nodes
  that are descendants of this node.