def attach_stream(self, stream):
        """Notify that we would like to attach a node input to this stream.

        The return value from this function is the DataStream that should be attached
        to since this function may internally allocate a new SGNode that copies the
        stream if there is no space in the output list to hold another input.

        This function should be called once for every node input before allocated a new
        sensor graph node that attaches to a stream that is managed by the StreamAllocator.

        Args:
            stream (DataStream): The stream (originally returned from allocate_stream)
                that we want to attach to.

        Returns:
            Datastream: A data stream, possible the same as stream, that should be attached
                to a node input.
        """

        curr_stream, count, prev = self._allocated_streams[stream]

        # Check if we need to split this stream and allocate a new one
        if count == (self.model.get(u'max_node_outputs') - 1):
            new_stream = self.allocate_stream(curr_stream.stream_type, previous=curr_stream)
            copy_desc = u"({} always) => {} using copy_all_a".format(curr_stream, new_stream)

            self.sensor_graph.add_node(copy_desc)
            self._allocated_streams[stream] = (new_stream, 1, curr_stream)

            # If we are splitting a constant stream, make sure we also duplicate the initialization value
            # FIXME: If there is no default value for the stream, that is probably a warning since all constant
            #        streams should be initialized with a value.
            if curr_stream.stream_type == DataStream.ConstantType and curr_stream in self.sensor_graph.constant_database:
                self.sensor_graph.add_constant(new_stream, self.sensor_graph.constant_database[curr_stream])

            return new_stream

        self._allocated_streams[stream] = (curr_stream, count + 1, prev)
        return curr_stream
Notify that we would like to attach a node input to this stream.

        The return value from this function is the DataStream that should be attached
        to since this function may internally allocate a new SGNode that copies the
        stream if there is no space in the output list to hold another input.

        This function should be called once for every node input before allocated a new
        sensor graph node that attaches to a stream that is managed by the StreamAllocator.

        Args:
            stream (DataStream): The stream (originally returned from allocate_stream)
                that we want to attach to.

        Returns:
            Datastream: A data stream, possible the same as stream, that should be attached
                to a node input.