/**
  * @param AbstractRevision $revision
  * @return AbstractRevision
  */
 protected function getRoot(AbstractRevision $revision)
 {
     if ($revision instanceof PostSummary) {
         $topicId = $revision->getSummaryTargetId();
     } elseif ($revision instanceof PostRevision && !$revision->isTopicTitle()) {
         try {
             $topicId = $revision->getCollection()->getWorkflowId();
         } catch (DataModelException $e) {
             // failed to locate root post (most likely in unit tests, where
             // we didn't store the tree)
             return $revision;
         }
     } else {
         // if we can't the revision it back to a root, this revision is root
         return $revision;
     }
     $collection = PostCollection::newFromId($topicId);
     return $collection->getLastRevision();
 }