def _cons2tuple(seq, couple_alone=None, astype=tuple):
    """
    >>> _cons2tuple((4,))
    4
    >>> _cons2tuple((4,), couple_alone=0, astype=list)
    [4, 0]
    >>> _cons2tuple((4, 5, 6, 7))
    (4, 7)
    """
    if len(seq) == 1:
        ret = seq[0]
        if couple_alone is not None:
            if couple_alone != 'duplicate':
                ret = astype((seq[0], couple_alone))
            else:
                ret = astype((seq[0], seq[0]))
        return ret
    return astype((min(seq), max(seq)))
