def is_prefix_code(iterable, is_sorted=False):
    """Tell whether a given list, identified by `iterable` is a prefix code.

    The prefix code is an attribute of lists, for which no element is
    prefix of another element in the list.

    We expect the elements of the list to be text/strings::

       >>> is_prefix_code(["a", "b", "c", "d"])
       True

       >>> is_prefix_code(["air", "airborn", "foo"])
       False

    If `is_sorted` is ``True``, we expect the iterable to be already
    sorted. If not, we will sort the list. Results are undefined for
    lists that are given as sorted, but are in fact not.

    """
    last_elem = None
    elems = iterable
    if not is_sorted:
        elems = sorted(iterable)
    for elem in elems:
        if last_elem and elem.startswith(last_elem):
            return False
        last_elem = elem
    return True
