mmentsClosuresOrRetracts
    :: (PersistEntity val, PersistEntityBackend val ~ SqlBackend)
    => EntityField val CommentId -> [CommentId] -> DB (Map CommentId [val])
commentsClosuresOrRetracts comment_field comment_ids =
    fmap (foldr step mempty) $
    select $
    from $ \(ca `InnerJoin` table) -> do
    on_ (ca ^. CommentAncestorAncestor ==. table ^. comment_field)
    orderBy [asc (table ^. comment_field)]
    where_ (ca ^. CommentAncestorComment `in_` valList comment_ids)
    return (ca ^. CommentAncestorComment, table)
  where
    step (Value c, Entity _ v) = M.insertWith (++) c [v]

-- | Get a comment's ancestors' ids.
f
commentsClosuresOrRetracts
    :: (PersistEntity val, PersistEntityBackend val ~ SqlBackend)
    => EntityField val CommentId -> [CommentId] -> DB (Map CommentId [val])
commentsClosuresOrRetracts comment_field comment_ids =
    fmap (foldr step mempty) $
    select $
    from $ \(ca `InnerJoin` table) -> do
    on_ (ca ^. CommentAncestorAncestor ==. table ^. comment_field)
    orderBy [asc (table ^. comment_field)]
    where_ (ca ^. CommentAncestorComment `in_` valList comment_ids)
    return (ca ^. CommentAncestorComment, table)
  where
    step (Value c, Entity _ v) = M.insertWith (++) c [v]

-- | Get a comment's ancestors' ids.
commentsClosuresOrRetracts comment_field comment_ids =
    fmap (foldr step mempty) $
    select $
    from $ \(ca `InnerJoin` table) -> do
    on_ (ca ^. CommentAncestorAncestor ==. table ^. comment_field)
    orderBy [asc (table ^. comment_field)]
    where_ (ca ^. CommentAncestorComment `in_` valList comment_ids)
    return (ca ^. CommentAncestorComment, table)
  where
    step (Value c, Entity _ v) = M.insertWith (++) c [v]

-- | Get a comment's ancestors' ids.