Helper function to get a stream or create one if it's not already defined

        :param stream_id: The stream id
        :param try_create: Whether to try to create the stream if not found
        :return: The stream object

def get_or_create_stream(self, stream_id, try_create=True):
        """
        Helper function to get a stream or create one if it's not already defined

        :param stream_id: The stream id
        :param try_create: Whether to try to create the stream if not found
        :return: The stream object
        """
        stream_id = get_stream_id(stream_id)
        if stream_id in self.streams:
            logging.debug("found {}".format(stream_id))
            return self.streams[stream_id]
        elif try_create:
            # Try to create the stream
            logging.debug("creating {}".format(stream_id))
            return self.create_stream(stream_id=stream_id)