public function getPath($pk = null, $allFields = false)
    {
        $k = $this->getKeyName();
        $pk = $pk === null ? $this->$k : $pk;

        // Get the path from the node to the root.
        $query = $this->db->getQuery(true)
            ->select('p.' . $k . ', p.parent_id, p.level, p.lft, p.rgt')
            ->from($this->db->quoteName($this->table) . ' AS n, ' . $this->db->quoteName($this->table) . ' AS p')
            ->where('n.lft BETWEEN p.lft AND p.rgt')
            ->where('n.' . $k . ' = ' . (int) $pk)
            ->order('p.lft');

        if ($allFields) {
            $query->select('p.*');
        }

        return $this->db->getReader($query)->loadObjectList();
    }