public function getNewPriority($book) { $lastElem = $this->getChildren($book)->pop(); return $lastElem ? $lastElem->priority + 1 : 0; }