def METHOD_NAME(cases, comm):
    """
    Coordinate worker processes.
    This runs only on rank 0.  It sends cases to all of the workers and
    collects their results.
    Parameters
    ----------
    cases : collection of function args
        Entries are assumed to be of the form (args, kwargs) where
        kwargs are allowed to be None and args should be a list or tuple.
    comm : MPI communicator or None
        The MPI communicator that is shared between the master and workers.
        If None, the function will be executed serially.
    Returns
    -------
    object
        Return from function.
    """
    received = 0
    sent = 0
    results = []
    case_iter = iter(cases)
    # seed the workers
    for i in range(1, comm.size):
        try:
            case = next(case_iter)
        except StopIteration:
            break
        if trace:
            debug('Master sending case', i)
        comm.send(case, i, tag=1)
        if trace:
            debug('Master sent case', i)
        sent += 1
    # send the rest of the cases
    if sent > 0:
        while True:
            # wait for any worker to finish
            worker, retval, err = comm.recv(tag=2)
            received += 1
            # store results
            results.append((retval, err))
            # don't stop until we hear back from every worker process
            # we sent a case to
            if received == sent:
                break
            try:
                case = next(case_iter)
            except StopIteration:
                pass
            else:
                # send new case to the last worker that finished
                comm.send(case, worker, tag=1)
                sent += 1
    # tell all workers to stop
    for rank in range(1, comm.size):
        comm.send((None, None), rank, tag=1)
    return results