def _check_rel(attrs, rel_whitelist, rel_blacklist):
        """ Check a link's relations against the whitelist or blacklist.

        First, this will reject based on blacklist.

        Next, if there is a whitelist, there must be at least one rel that matches.
        To explicitly allow links without a rel you can add None to the whitelist
        (e.g. ['in-reply-to',None])
        """

        rels = attrs.get('rel', [None])

        if rel_blacklist:
            # Never return True for a link whose rel appears in the blacklist
            for rel in rels:
                if rel in rel_blacklist:
                    return False

        if rel_whitelist:
            # If there is a whitelist for rels, only return true for a rel that
            # appears in it
            for rel in rels:
                if rel in rel_whitelist:
                    return True
            # If there is a whitelist and we don't match, then reject
            return False

        return True
Check a link's relations against the whitelist or blacklist.

        First, this will reject based on blacklist.

        Next, if there is a whitelist, there must be at least one rel that matches.
        To explicitly allow links without a rel you can add None to the whitelist
        (e.g. ['in-reply-to',None])