def calc_column_lighting(x, z, mclevel):
    '''Recalculate the sky lighting of the column.'''

    # Begin at the top with sky light level 15.
    cur_light = 15
    # traverse the column until cur_light == 0
    # and the existing light values are also zero.
    y = 255
    get_block = mclevel.block
    set_block = mclevel.set_block
    get_height = mclevel.retrieve_heightmap
    set_height = mclevel.set_heightmap
    #get the current heightmap
    cur_height = get_height(x, z)
    # set a flag that the highest point has been updated
    height_updated = False
    # if this doesn't exist, the block doesn't exist either, abort.
    if cur_height is None:
        return None
    light_reduction_lookup = {0: 0, 20: 0, 18: 1, 8: 2, 79: 2}
    while True:
        #get the block sky light and type
        block_info = get_block(x, y, z, 'BS')
        block_light = block_info['S']
        block_type = block_info['B']
        # update the height map if it hasn't been updated yet,
        # and the current block reduces light
        if (not height_updated) and (block_type not in (0, 20)):
            new_height = y + 1
            if new_height == 256:
                new_height = 255
            set_height(x, new_height, z)
            height_updated = True
        #compare block with cur_light, escape if both 0
        if block_light == 0 and cur_light == 0:
            break
        #set the block light if necessary
        if block_light != cur_light:
            set_block(x, y, z, {'S': cur_light})
        #set the new cur_light
        if block_type in light_reduction_lookup:
            # partial light reduction
            light_reduction = light_reduction_lookup[block_type]
        else:
            # full light reduction
            light_reduction = 16
        cur_light += -light_reduction
        if cur_light < 0:
            cur_light = 0
        #increment and check y
        y += -1
        if y < 0:
            break
Recalculate the sky lighting of the column.
stock-filters/Forester.py