code: def get_tree_leaves_mask(tree) -> np.ndarray:
      """
      Get mask array for tree leaves
      Args:
          tree: CausalTreeRegressor
                Tree object
      Returns: np.ndarray
               Mask array
  
      """
      n_nodes = tree.tree_.node_count
      children_left = tree.tree_.children_left
      children_right = tree.tree_.children_right
  
      node_depth = np.zeros(shape=n_nodes, dtype=np.int64)
      is_leaves = np.zeros(shape=n_nodes, dtype=bool)
      stack = [(0, 0)]
      while len(stack) > 0:
          node_id, depth = stack.pop()
          node_depth[node_id] = depth
  
          is_split_node = (
              children_left[node_id] != children_right[node_id]
          )
  
          if is_split_node:
              stack.append((children_left[node_id], depth + 1))
              stack.append((children_right[node_id], depth + 1))
          else:
              is_leaves[node_id] = True
      return is_leaves
  
file_path: causalml/causalml/inference/tree/utils.py
imports: import time
  from typing import Callable
  import numpy
  import pandas
label_desc: Use image node_id 6 for calling a global function with example usage: get_tree_leaves_mask(tree) and returns: is_leaves