public function rebuild($parent_id = 0, $left = 0)
	{
		// get all children of this node
		$children = self::all()
			->select('id')
			->whereEquals('parent_id', (int) $parent_id)
			->order('parent_id', 'asc')
			->rows();

		// the right value of this node is the left value + 1
		$right = $left + 1;

		// execute this function recursively over all children
		foreach ($children as $child)
		{
			// $right is the current right value, which is incremented on recursion return
			$right = $this->rebuild($child->get('id'), $right);

			// if there is an update failure, return false to break out of the recursion
			if ($right === false)
			{
				return false;
			}
		}

		// we've got the left value, and now that we've processed
		// the children of this node we also know the right value
		$query = $this->getQuery()
			->update($this->getTableName())
			->set(array(
				'lft' => (int) $left,
				'rgt' => (int) $right
			))
			->whereEquals('id', (int) $parent_id);

		// if there is an update failure, return false to break out of the recursion
		if (!$query->execute())
		{
			return false;
		}

		// return the right value of this node + 1
		return $right + 1;
	}