def make_connections_from_connect_streams(connect_streams):
    """
    Converts from the format of connect_streams to the format of
    connections.
    connect_streams is a list of 4-tuples:
        sender_process, out_stream, receiver_process, in_stream
    connections is a dict where
        connections[sender_process] is a dict where
        connections[sender_process][out_stream_name] is a list of 2-tuples
        (receiver_process, in_stream_name)
    In this code, sender_process, out_stream, receiver_process, in_stream
    refer to the NAMES of the sender process, output stream receiver process
    and input stream.
    """
    connections = {}
    for four_tuple in connect_streams:
        sender_process, out_stream, receiver_process, in_stream = four_tuple
        if not sender_process in connections.keys():
            # Create dict and then enter the first tuple
            # (receiver_process, in_stream) into empty list.
            connections[sender_process] = {}
            connections[sender_process][out_stream] = \
              [(receiver_process, in_stream)]
        else:
            if not out_stream in connections[sender_process].keys():
                # Enter the first tuple (receiver_process, in_stream)
                # into an empty list.
                connections[sender_process][out_stream] = \
                  [(receiver_process, in_stream)]
            else:
                # Append tuple to the existing list.
                connections[sender_process][out_stream].append(
                    (receiver_process, in_stream))
    return connections