public function getDraft(AbstractClassContent $content, BBUserToken $token, $checkoutOnMissing = false)
    {
        if (null === $revision = $content->getDraft()) {
            try {
                if (false === $this->_em->contains($content)) {
                    $content = $this->_em->find(get_class($content), $content->getUid());
                    if (null === $content) {
                        return;
                    }
                }

                $q = $this->createQueryBuilder('r')
                    ->andWhere('r._content = :content')
                    ->andWhere('r._owner = :owner')
                    ->andWhere('r._state IN (:states)')
                    ->orderBy('r._revision', 'desc')
                    ->orderBy('r._modified', 'desc')
                    ->setParameters([
                        'content' => $content,
                        'owner'   => '' . UserSecurityIdentity::fromToken($token),
                        'states'  => [Revision::STATE_ADDED, Revision::STATE_MODIFIED, Revision::STATE_CONFLICTED],
                    ])
                    ->getQuery()
                ;

                $revision = $q->getSingleResult();
            } catch (NoResultException $e) {
                if ($checkoutOnMissing) {
                    $revision = $this->checkout($content, $token);
                    $this->_em->persist($revision);
                } else {
                    $revision = null;
                }
            } catch (NonUniqueResultException $e) {
                $drafts = $q->getResult();
                $revision = array_shift($drafts);
                foreach ($drafts as $draft) {
                    $this->_em->remove($draft);
                    $this->_em->flush($draft);
                }

            }
        }

        return $revision;
    }