def normalize(r, construct=range):
    """
    Return an object which is the normalization of range *r*.

    The normalized range is either None (if r.start >= r.stop), or an object
    constructed using *construct* with the arguments r.start, r.stop.

    In case construct == range we try to avoid constructing new objects.
    """
    if r is None:
        return None
    if r.stop <= r.start:
        return None
    else:
        if construct == range and isinstance(r, range) and r.step == 1:
            return r
        else:
            return construct(r.start, r.stop)