public function getParent()
    {
        if($this->isRoot())
        {
            return null;
        }

        if($this->parent == null && $this->ancestors)
        {
            // Shortcut if we already loaded the ancestors
            $this->parent = $this->ancestors[count($this->ancestors)-1];
        }

        if($this->parent == null)
        {
            $qb = $this->getManager()->getConfiguration()->getBaseQueryBuilder();
            $alias = $this->getManager()->getConfiguration()->getQueryBuilderAlias();

            $qb->andWhere("$alias.".$this->getLeftFieldName()." < :lft1")
                ->setParameter('lft1', $this->getLeftValue())
                ->andWhere("$alias.".$this->getRightFieldName()." > :rgt1")
                ->setParameter('rgt1', $this->getRightValue())
                ->orderBy("$alias.".$this->getRightFieldName(), "ASC")
                ->setMaxResults(1);
            if($this->hasManyRoots())
            {
                $qb->andWhere("$alias.".$this->getRootFieldName()." = :root")
                    ->setParameter('root', $this->getRootValue());
            }

			$q = $qb->getQuery();
			if ($this->getManager()->getConfiguration()->isQueryHintSet()){
				$q = $this->getManager()->addHintToQuery($q);
			}
			$results = $q->getResult();
			
            $this->parent = $this->getManager()->wrapNode($results[0]);
        }

        return $this->parent;
    }