code: def convert_tree_leaves_into_filters(
      tree, feature_names: List[str]
  ) -> List[DeepchecksBaseFilter]:
      """Extract the leaves from a sklearn tree and covert them into DeepchecksBaseFilter.
  
      The function goes over the tree from root to leaf and concatenates (by intersecting) the relevant filters along the
      way. The function returns a list in which each element is a DeepchecksFilter representing the path between the root
      to a different leaf.
  
      Parameters
      ----------
      tree : A sklearn tree. The tree_ property of a sklearn decision tree.
      feature_names : List[str]
          The feature names for elements within the tree. Normally it is the column names of the data frame the tree
             was trained on.
  
      Returns
      -------
      List[DeepchecksFilter]:
             A list of filters describing the leaves of the tree.
      """
      node_to_feature = [
          feature_names[feature_idx]
          if feature_idx != _tree.TREE_UNDEFINED
          else None
          for feature_idx in tree.feature
      ]
  
      def recurse(node_idx: int, filter_of_node: DeepchecksBaseFilter):
          if tree.feature[node_idx] != _tree.TREE_UNDEFINED:
              left_node_filter = filter_of_node.copy().add_filter(
                  node_to_feature[node_idx],
                  tree.threshold[node_idx],
                  greater_then=False,
              )
              right_node_filter = filter_of_node.copy().add_filter(
                  node_to_feature[node_idx], tree.threshold[node_idx]
              )
  
              return recurse(
                  tree.children_left[node_idx], left_node_filter
              ) + recurse(
                  tree.children_right[node_idx], right_node_filter
              )
          else:
              return [filter_of_node]
  
      filters_to_leaves = recurse(0, DeepchecksBaseFilter())
      return filters_to_leaves
  
imports: from collections import defaultdict
  from copy import deepcopy
  from typing import Callable, List, Optional, Tuple, Union
  import numpy
  import pandas
  from sklearn.tree import _tree
  from deepchecks.tabular.dataset import Dataset
  from deepchecks.utils.strings import format_number
  from deepchecks.utils.typing import Hashable
label_desc: Use image node_id 6 for calling a global function with example usage: convert_tree_leaves_into_filters(tree, feature_names) and returns: filters_to_leaves, unknown, list