def store(self, parents, value):
        if len(parents) != self.parentCount:
            raise ValueError('You must supply %d values' % self.parentCount)

        p_indexes = range(len(parents))

        if not isinstance(value, TreeLeaf):
            value = TreeLeaf(value)
        tree = self.tree
        while True:
            if tree.isLeaf():
                if p_indexes:
                    # Start branching in leaf, create new default branch as
                    # copy of this leaf
                    tree.default = deepcopy(tree)
                    tree.parentId = p_indexes.pop(0)
                    continue
                else:
                    # Overwrite stored value
                    tree.default = value
                    break
            else:
                p_id = tree.parentId
                p_val = parents[p_id]
                if p_val in tree:
                    # Descent in tree
                    tree = tree[p_val]
                    if p_id in p_indexes:
                        p_indexes.remove(p_id)
                else:
                    if p_indexes:
                        # Insert new subtree
                        new_p_id = p_indexes.pop(0)
                        new_default = deepcopy(tree.default)
                        new_tree = TreeBranch(new_p_id, new_default)
                        tree[p_val] = new_tree
                        tree = new_tree
                    else:
                        # Make leaf
                        tree[p_val] = TreeBranch(_LEAF, value)
                        break
dataset/ETHPy150Open uci-cbcl/tree-hmm/gmtkParam/__init__.py/DT.store/original