/**
* Also deletes the nodes in the subtree of the entity to be delete
*
* @param \Cake\Event\Event the beforeDelete event that was fired
* @param \Cake\ORM\Entity the entity that is going to be saved
* @return void
*/
public function beforeDelete(Event $event, Entity $entity)
{
$config = $this->config();
$this->_ensureFields($entity);
$left = $entity->get($config['left']);
$right = $entity->get($config['right']);
$diff = $right - $left + 1;
if ($diff > 2) {
$this->_table->deleteAll(["{$config['left']} >=" => $left + 1, "{$config['left']} <=" => $right - 1]);
}
$this->_sync($diff, '-', "> {$right}");
}