public function findNextSubcategory($subcategory)
    {
        $qb = $this->getQueryBuilder()
            ->select('c')
            ->where('c.id > :id')
            ->andWhere('c.parentCategory = :parentCategory')
            ->orderBy('c.id', 'asc')
            ->setMaxResults(1)
            ->setParameter('id', $subcategory->getId())
            ->setParameter('parentCategory', $subcategory->getParentCategory());

        // get the first subcategory when there is no next
        if (0 == count($qb->getQuery()->getResult())) {
            $qb->where('c.id < :id')
                ->andWhere('c.parentCategory = :parentCategory')
                ->setParameter('id', $subcategory->getId())
                ->setParameter('parentCategory', $subcategory->getParentCategory());

            if (0 == count($qb->getQuery()->getResult())) {
                return null;
            }
        }

        return $qb->getQuery()
            ->getSingleResult();
    }