def search_stack_for_localvar(varname):
    """
    Finds a local varable somewhere in the stack and returns the value

    Args:
        varname (str): variable name

    Returns:
        None if varname is not found else its value
    """
    curr_frame = inspect.currentframe()
    print(' * Searching parent frames for: ' + six.text_type(varname))
    frame_no = 0
    while curr_frame.f_back is not None:
        if varname in curr_frame.f_locals.keys():
            print(' * Found in frame: ' + six.text_type(frame_no))
            return curr_frame.f_locals[varname]
        frame_no += 1
        curr_frame = curr_frame.f_back
    print('... Found nothing in all ' + six.text_type(frame_no) + ' frames.')
    return None
Finds a local varable somewhere in the stack and returns the value

    Args:
        varname (str): variable name

    Returns:
        None if varname is not found else its value