'Return latest ready-to-localize revision if there is one,
else the latest approved revision if there is one,
else the latest unrejected (unreviewed) revision if there is one,
else None.
include_rejected -- If true, fall back to the latest rejected
revision if all else fails.'

def localizable_or_latest_revision(self, include_rejected=False):

    def latest(queryset):
        'Return    the    latest    item    from    a    queryset    (by    ID).\n\n                                                Return    None    if    the    queryset    is    empty.\n\n                                                '
        try:
            return queryset.order_by('-id')[0:1].get()
        except ObjectDoesNotExist:
            return None
    rev = self.latest_localizable_revision
    if ((not rev) or (not self.is_localizable)):
        rejected = Q(is_approved=False, reviewed__isnull=False)
        rev = (latest(self.revisions.filter(is_approved=True)) or latest(self.revisions.exclude(rejected)) or (latest(self.revisions) if include_rejected else None))
    return rev
