'Undo collapsing for special comments.
The builder may have set `collapsed` and `hidden` attributes for
comments that we want to ensure are shown.'

def uncollapse_special_comments(self, wrapped_by_id):

    if self.uncollapse_all:
        dont_collapse = set(wrapped_by_id.keys())
    elif self.comment:
        dont_collapse = set([self.comment._id])
        parent_id = self.comment.parent_id
        while parent_id:
            dont_collapse.add(parent_id)
            if (parent_id in wrapped_by_id):
                parent_id = wrapped_by_id[parent_id].parent_id
            else:
                parent_id = None
    elif self.children:
        dont_collapse = set(self.children)
    else:
        dont_collapse = set()
    dont_collapse &= set(wrapped_by_id.keys())
    maybe_collapse = (set(wrapped_by_id.keys()) - dont_collapse)
    for comment_id in maybe_collapse:
        comment = wrapped_by_id[comment_id]
        if (comment.distinguished and (comment.distinguished != 'no')):
            dont_collapse.add(comment_id)
    maybe_collapse -= dont_collapse
    if maybe_collapse:
        for comment_id in sorted(dont_collapse):
            comment = wrapped_by_id[comment_id]
            parent_id = comment.parent_id
            counter = 0
            while (parent_id and (parent_id not in dont_collapse) and (parent_id in wrapped_by_id) and (counter < g.max_comment_parent_walk)):
                dont_collapse.add(parent_id)
                counter += 1
                comment = wrapped_by_id[parent_id]
                parent_id = comment.parent_id
    for comment_id in dont_collapse:
        comment = wrapped_by_id[comment_id]
        if comment.collapsed:
            comment.collapsed = False
            comment.hidden = False
