code: def _extract_arrays_from_figs_tree(figs_tree):
      """Takes in a FIGS tree and recursively converts it to arrays that we can later use to build a sklearn decision tree object"""
      tree_data = TreeData(
          left_child=[],
          right_child=[],
          feature=[],
          threshold=[],
          impurity=[],
          n_node_samples=[],
          weighted_n_node_samples=[],
          missing_go_to_left=[],
      )
  
      value_sklearn_array = []
  
      def _update_node(node):
          if node is None:
              return
  
          node_id_left = node_id_right = -1
          feature = threshold = -2
          value_sklearn = node.value_sklearn
  
          has_children = node.left is not None
          if has_children:
              node_id_left = node.left.node_id
              node_id_right = node.right.node_id
              feature = node.feature
              threshold = node.threshold
  
          tree_data.left_child.append(node_id_left)
          tree_data.right_child.append(node_id_right)
          tree_data.feature.append(feature)
          tree_data.threshold.append(threshold)
          tree_data.impurity.append(node.impurity)
          tree_data.n_node_samples.append(np.sum(value_sklearn))
          tree_data.weighted_n_node_samples.append(
              np.sum(value_sklearn)
          )  # TODO add sample weights
          tree_data.missing_go_to_left.append(1)
          value_sklearn_array.append(value_sklearn)
  
          if has_children:
              _update_node(node.left)
              _update_node(node.right)
  
      _update_node(figs_tree)
  
      return tree_data, np.array(value_sklearn_array)
  
file_path: imodels/imodels/tree/viz_utils.py
imports: import numpy
  import pandas
  from collections import namedtuple
  from sklearn import __version__
  from sklearn.base import ClassifierMixin, RegressorMixin
  from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
  from sklearn.tree._tree import Tree
label_desc: Use image node_id 1 for calling a global function with example usage: _extract_arrays_from_figs_tree(figs_tree) and returns: tree_data,  np