def spritecollideany(sprite, group, collided = None):
    """pygame.sprite.spritecollideany(sprite, group) -> sprite
       finds any sprites that collide

       given a sprite and a group of sprites, this will
       return return any single sprite that collides with
       with the given sprite. If there are no collisions
       this returns None.

       if you don't need all the features of the
       spritecollide function, this function will be a
       bit quicker.

       collided is a callback function used to calculate if
       two sprites are colliding. it should take two sprites
       as values, and return a bool value indicating if
       they are colliding. if collided is not passed, all
       sprites must have a "rect" value, which is a
       rectangle of the sprite area, which will be used
       to calculate the collision."""
    if collided is None:
        # Special case old behaviour for speed.
        spritecollide = sprite.rect.colliderect
        for s in group:
            if spritecollide(s.rect):
                return s
    else:
        for s in group:
            if collided(sprite, s):
                return s
    return None