def METHOD_NAME(name, rank):
    #if name.startswith(unassigned):
    #    name = name[len(unassigned):]
    m = sub.match(name)
    if m != None:
        # Four cases:
        #  Gg (Sub) sp  -> Gg sp
        #  Gg (Sub)     -> Sub
        #  Gs (Gs) sp   -> Gs sp
        #  Gs (Gs)      -> Gs subgenus Gs
        if m.group(3) != '':
            name = ('%s%s' % (m.group(1), m.group(3)))
        elif m.group(1) == m.group(2):
            name = ('%s %s %s%s' %
                    (m.group(1), rank, m.group(2), m.group(3)))
        else:
            name = m.group(2)
    return name