def get_first_valid(request, objects, product=None):
    """
    Returns the first valid object of given objects.

    Passed object is an object which can have criteria. At the moment these are
    discounts, shipping/payment methods and shipping/payment prices.
    """
    for object in objects:
        if object.is_valid(request, product):
            return object
    return None