public function remove($recursive = false) { if ($recursive) { $children = $this->getDescendantsId(); $this->_db->delete($this->_table, array($this->_pk => $children)); parent::remove(); } else { $children = $this->getChildren(); if (count($children)) { throw new Model_Exception("Can't remove non-leaf tree item"); } else { parent::remove(); } } }