def _vectorize_tree(tree):
    """
    vectorize the tree
    Args:
        tree: RegressionTreeProto
    Returns:
        vec: vectorized information dict in a tree
            {
                'is_owner': np.bool, if it is the owner of the node,
                'feature_id': np.int32, the serial number of each feature,
                              continuous features first, categorical features
                              after
                'is_cat_feature': np.bool, if the feature is the categorical
                                feature
                'threshold': np.int32, the threshold of continuous features,
                'cat_threshold': List, the threshold of categorical features,
                'default_left': np.bool, if default left when it is null,
                'is_leaf': np.bool, if it is the leaf node,
                'weight': np.float, the weight of the node,
                'children': np.int32, the left and the right child
                            node serial number,
                'parent': np.int32, the parent node serial number
            }
    """
    vec = {}
    vec['is_owner'] = np.asarray([n.is_owner for n in tree.nodes])
    vec['feature_id'] = np.asarray([n.feature_id for n in tree.nodes])
    vec['is_cat_feature'] = np.asarray([n.is_cat_feature for n in tree.nodes])
    vec['threshold'] = np.asarray([n.threshold for n in tree.nodes])
    vec['cat_threshold'] = [np.asarray(n.cat_threshold) for n in tree.nodes]
    vec['default_left'] = np.asarray(
        [n.default_left for n in tree.nodes], dtype=np.bool)
    vec['is_leaf'] = np.asarray([n.left_child == 0 for n in tree.nodes])
    vec['weight'] = np.asarray([n.weight for n in tree.nodes])
    vec['children'] = np.asarray([
        [n.left_child for n in tree.nodes],
        [n.right_child for n in tree.nodes]])
    vec['parent'] = np.asarray([n.parent for n in tree.nodes])
    return vec

    vectorize the tree
    Args:
        tree: RegressionTreeProto
    Returns:
        vec: vectorized information dict in a tree
            {
                'is_owner': np.bool, if it is the owner of the node,
                'feature_id': np.int32, the serial number of each feature,
                              continuous features first, categorical features
                              after
                'is_cat_feature': np.bool, if the feature is the categorical
                                feature
                'threshold': np.int32, the threshold of continuous features,
                'cat_threshold': List, the threshold of categorical features,
                'default_left': np.bool, if default left when it is null,
                'is_leaf': np.bool, if it is the leaf node,
                'weight': np.float, the weight of the node,
                'children': np.int32, the left and the right child
                            node serial number,
                'parent': np.int32, the parent node serial number
            }
    
fedlearner/model/tree/tree.py