def _send_output_to_connected_nodes(node, output):
    """Send output to nodes connected to the given one.

    If the given one has connections to other nodes.

    Parameters
    ==========

    node (graphman.callablenode.main.CallableNode or subclass)
        node from which the output was produced.
    output (any Python value)
        output produced by the given node.
    """
    ### retrieve iterable with all output sockets from the given node
    ###
    ### note that whenever traversing the graph, we usually only worry
    ### about the 'output_sockets' collections, but here we check the
    ### existence of the live map as well;
    ###
    ### the reason for that is that here we need to know the number of
    ### existing output sockets rather than the number of output sockets
    ### with connections; when traversing we only care about the connected
    ### ones, but here we need to know the exact number because if it
    ### is higher than 1 it means the expected output is a mapping containing
    ### each output; that is why only here we worry about the output
    ### socket live map, which is present in all callable nodes and their
    ### subclasses, except the operator nodes, since they only ever
    ### have a single output socket in signature mode

    if hasattr(node, 'output_socket_live_map'):
        output_sockets = node.output_socket_live_map.values()

    else:
        output_sockets = node.output_sockets

    ### now that we retrieved the appropriate collection of references
    ### to the existing output sockets, we can properly obtain its length,
    ### that is, the quantity of output sockets, and treat the output
    ### according to that quantity

    ## if there's more than one socket, then the output received is expected
    ## to be a mapping;
    ##
    ## each output socket has an output name that serves as a key to retrieve
    ## a value from this mapping that must be sent via that output socket
    ## (if that socket has children)

    if len(output_sockets) > 1:

        ## iterate over each socket, checking whether
        ## it has children and, if so, retrieving its
        ## specific value to be sent to them

        for socket in output_sockets:

            try:
                children = socket.children

            except AttributeError:
                pass

            else:

                ## try retrieving value to be sent

                try:
                    value_to_be_sent = output[socket.output_name]

                ## if not possible, raise a missing
                ## output error to notify user of
                ## the problem

                except (TypeError, KeyError) as err:

                    ## create iterator with output
                    ## names of output sockets

                    expected_outputs = (
                        socket.output_name
                        for socket in output_sockets
                    )

                    ## pass relevant data to the
                    ## exception constructor and
                    ## raise it from the original
                    ## exception

                    raise UnexpectedOutputError(
                        node, expected_outputs
                    ) from err

                ## send value to each child

                else:

                    for child in children:
                        child.receive_input(value_to_be_sent)

    ### otherwise, if we have only one output socket, the output received
    ### is itself the value to be sent to the output socket children, if it
    ### has children

    else:

        for socket in output_sockets:

            try:
                children = socket.children

            except AttributeError:
                pass

            else:

                for child in children:
                    child.receive_input(output)
Send output to nodes connected to the given one.

    If the given one has connections to other nodes.

    Parameters
    ==========

    node (graphman.callablenode.main.CallableNode or subclass)
        node from which the output was produced.
    output (any Python value)
        output produced by the given node.
    
nodezator/graphman/execution.py