def tsses(db, merge_overlapping=False, attrs=None, attrs_sep=":",
          merge_kwargs=None, as_bed6=False, bedtools_227_or_later=True):
    _override = os.environ.get('GFFUTILS_USES_BEDTOOLS_227_OR_LATER', None)
    if _override is not None:
        if _override == 'true':
            bedtools_227_or_later = True
        elif _override == 'false':
            bedtools_227_or_later = False
        else:
            raise ValueError(
                "Unknown value for GFFUTILS_USES_BEDTOOLS_227_OR_LATER "
                "environment variable: {0}".format(_override))
    if bedtools_227_or_later:
        _merge_kwargs = dict(o='distinct', s=True, c='4,5,6')
    else:
        _merge_kwargs = dict(o='distinct', s=True, c='4')
    if merge_kwargs is not None:
        _merge_kwargs.update(merge_kwargs)
    def gen():
        for gene in db.features_of_type('gene'):
            for transcript in db.children(gene, level=1):
                if transcript.strand == '-':
                    transcript.start = transcript.stop
                else:
                    transcript.stop = transcript.start
                transcript.featuretype = transcript.featuretype + '_TSS'
                yield helpers.asinterval(transcript)
    x = pybedtools.BedTool(gen()).sort()
    if attrs is None:
        if db.dialect['fmt'] == 'gtf':
            attrs = 'gene_id'
        else:
            attrs = 'ID'
    if merge_overlapping or as_bed6:
        if isinstance(attrs, six.string_types):
            attrs = [attrs]
        def to_bed(f):
            name = attrs_sep.join([f.attrs[i] for i in attrs])
            return pybedtools.Interval(
                f.chrom,
                f.start,
                f.stop,
                name,
                str(f.score),
                f.strand)
        x = x.each(to_bed).saveas()
    if merge_overlapping:
        if bedtools_227_or_later:
            x = x.merge(**_merge_kwargs)
        else:
            def fix_merge(f):
                f = featurefuncs.extend_fields(f, 6)
                return pybedtools.Interval(
                    f.chrom,
                    f.start,
                    f.stop,
                    f[4],
                    '.',
                    f[3])
            x = x.merge(**_merge_kwargs).saveas().each(fix_merge).saveas()
    return x