given a BED file or list of BED files merge them an return a bedtools object

def merge(bedfiles):
    """
    given a BED file or list of BED files merge them an return a bedtools object
    """
    if isinstance(bedfiles, list):
        catted = concat(bedfiles)
    else:
        catted = concat([bedfiles])
    if catted:
        return concat(bedfiles).sort().merge()
    else:
        return catted