Wait for a possible asynchronous value to complete.

def wait(value, must_be_child=False):
    '''Wait for a possible asynchronous value to complete.
    '''
    current = getcurrent()
    parent = current.parent
    if must_be_child and not parent:
        raise MustBeInChildGreenlet('Cannot wait on main greenlet')
    return parent.switch(value) if parent else value