/**
* Method to get an array of nodes from a given node to its root.
*
* @param integer $pk Primary key of the node for which to get the path.
* @param boolean $diagnostic Only select diagnostic data for the nested sets.
*
* @return mixed An array of node objects including the start node.
*
* @since 1.7.0
* @throws \RuntimeException on database error
*/
public function getPath($pk = null, $diagnostic = false)
{
$k = $this->_tbl_key;
$pk = \is_null($pk) ? $this->{$k} : $pk;
// Get the path from the node to the root.
$select = $diagnostic ? 'p.' . $k . ', p.parent_id, p.level, p.lft, p.rgt' : 'p.*';
$query = $this->_db->getQuery(true)->select($select)->from($this->_tbl . ' AS n, ' . $this->_tbl . ' AS p')->where('n.lft BETWEEN p.lft AND p.rgt')->where('n.' . $k . ' = ' . (int) $pk)->order('p.lft');
$this->_db->setQuery($query);
return $this->_db->loadObjectList();
}