<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

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