def insert(tree, sym, ba):
    """
    Insert symbol which is mapped to bitarray into tree
    """
    v = ba[0]
    if len(ba) > 1:
        if tree[v] == []:
            tree[v] = [[], []]
        insert(tree[v], sym, ba[1:])
    else:
        if tree[v] != []:
            raise ValueError("prefix code ambiguous")

        tree[v] = sym
dataset/ETHPy150Open pearu/pylibtiff/libtiff/bitarray-0.3.5-numpy/examples/decoding.py/insert/original