Generates pairs of values representing a cycle. E.g. clock hours for a day could
        could be generated with:
            _cycle_generator(cycle=(1, 12), step=1, begin=(0, 1), end=(23, 12))
                => (0, 1), (0, 2) ... (0, 12), (1, 1), (1, 2)

def cycle_generator(cycle, step=1, begin=(0, 0), end=None):
    '''
        Generates pairs of values representing a cycle. E.g. clock hours for a day could
        could be generated with:
            _cycle_generator(cycle=(1, 12), step=1, begin=(0, 1), end=(23, 12))
                => (0, 1), (0, 2) ... (0, 12), (1, 1), (1, 2)
    '''
    (cycle_begin, cycle_end) = cycle
    (major, minor) = begin
    (end_major, end_minor) = end if end is not None else (None, None)

    while True:
        if end is not None and (major > end_major or (major == end_major and minor > end_minor)):
            return
        yield (major, minor)
        minor += step
        if minor > cycle_end:
            major += 1
            minor = cycle_begin