def trim_bst(root, min, max):
    """Select a range from a binary search tree between ``min`` and ``max``.

    Arguments:
        root (binary search tree):
            The root of a binary search tree. A binary tree is either a 3-tuple
            ``(data, left, right)`` where ``data`` is the value of the root node
            and ``left`` and ``right`` are the left and right subtrees or
            ``None`` for the empty tree. A binary search tree is a binary tree
            whose in-order traversal is sorted.
        min:
            The minimum value of the trim.
        max:
            The maximum value of the trim.

    Returns:
        new_root (binary search tree):
            A new binary search tree that is like the input, but only contains
            nodes with values between ``min`` and ``max``, inclusive.
    """
    if root is None:
        return None

    (data, left, right) = root

    if data < min:
        return trim_bst(right, min, max)
    elif max < data:
        return trim_bst(left, min, max)
    else:
        new_left = trim_bst(left, min, max)
        new_right = trim_bst(right, min, max)
        return (data, new_left, new_right)