def build_tree()

in eland/ml/transformers/lightgbm.py [0:0]


    def build_tree(self, tree_id: int, tree_json_obj: Dict[str, Any]) -> Tree:
        tree_nodes = list()
        next_id = Counter()

        def add_tree_node(tree_node_json_obj: Dict[str, Any], counter: Counter) -> int:
            curr_id = counter.value()
            if "leaf_value" in tree_node_json_obj:
                tree_nodes.append(
                    self.make_leaf_node(tree_id, curr_id, tree_node_json_obj)
                )
                return curr_id
            left_id = add_tree_node(tree_node_json_obj["left_child"], counter.inc())
            right_id = add_tree_node(tree_node_json_obj["right_child"], counter.inc())
            tree_nodes.append(
                self.make_inner_node(
                    tree_id, curr_id, tree_node_json_obj, left_id, right_id
                )
            )
            return curr_id

        add_tree_node(tree_json_obj["tree_structure"], next_id)
        tree_nodes.sort(key=lambda n: n.node_idx)
        return Tree(
            feature_names=self._feature_names,
            target_type=self.determine_target_type(),
            tree_structure=tree_nodes,
        )