A helper function for Node subclass constructors -- if ``value``
    is a Node instance, extracts raw Python value and location from it,
    and returns them as a tuple.  Otherwise, ensures that ``value`` is
    of a type representable by S-expressions and returns it along with
    explicitly-passed location, if any.

def _unwrap(value, location=None):
    """A helper function for Node subclass constructors -- if ``value``
    is a Node instance, extracts raw Python value and location from it,
    and returns them as a tuple.  Otherwise, ensures that ``value`` is
    of a type representable by S-expressions and returns it along with
    explicitly-passed location, if any.
    """
    if isinstance(value, Node) and location is not None:
        raise TypeError(
                'explicit location should only be given for bare values')
    if isinstance(value, AtomNode):
        return value.value, value.location
    if isinstance(value, ListNode):
        return value.items, value.location
    if isinstance(value, FormNode):
        return value.to_list(), value.location
    if value is None or isinstance(value, (
            bool, BinInt, BinWord, BinArray, str, Symbol, tuple)):
        return value, location
    if isinstance(value, list):
        return tuple(value), location
    if isinstance(value, int):
        return BinInt(value), location
    raise TypeError(
            f'{type(value).__name__} is not representable by S-expressions.')