code: def validate_traversed_tree(
      tree,
      tree_dict,
      max_split_index,
      feature_names,
      df,
      parent_id=None,
  ):
      if SPLIT_INDEX in tree:
          nodeid = tree[SPLIT_INDEX]
      elif LEAF_INDEX in tree:
          nodeid = max_split_index + tree[LEAF_INDEX]
      else:
          nodeid = 0
  
      assert tree_dict[nodeid]["id"] == nodeid
      assert tree_dict[nodeid]["parentId"] == parent_id
      if SPLIT_FEATURE in tree:
          node_name = feature_names[tree[SPLIT_FEATURE]]
      else:
          node_name = None
      assert tree_dict[nodeid]["nodeName"] == node_name
      if INTERNAL_COUNT in tree:
          assert tree[INTERNAL_COUNT] == tree_dict[nodeid][SIZE]
      else:
          assert tree[LEAF_COUNT] == tree_dict[nodeid][SIZE]
  
      # validate children
      if "leaf_value" not in tree:
          left_child = tree[TreeSide.LEFT_CHILD]
          right_child = tree[TreeSide.RIGHT_CHILD]
          validate_traversed_tree(
              left_child,
              tree_dict,
              max_split_index,
              feature_names,
              df,
              nodeid,
          )
          validate_traversed_tree(
              right_child,
              tree_dict,
              max_split_index,
              feature_names,
              df,
              nodeid,
          )
  
imports: import re
  import time
  from enum import Enum
  import numpy
  import pandas
  import pytest
  from common_utils import replicate_dataset
  from erroranalysis._internal.cohort_filter import filter_from_cohort
  from erroranalysis._internal.constants import ARG, COLUMN, COMPOSITE_FILTERS, DIFF, LEAF_INDEX, METHOD, OPERATION, PRED_Y, ROW_INDEX, SPLIT_FEATURE, SPLIT_INDEX, TRUE_Y, CohortFilterMethods, CohortFilterOps, Metrics, ModelTask, regression_metrics
  from erroranalysis._internal.error_analyzer import ModelAnalyzer, PredictionsAnalyzer
  from erroranalysis._internal.surrogate_error_tree import TreeSide, cache_subtree_features, compute_error_tree, create_surrogate_model, get_categorical_info, get_max_split_index, traverse
  from rai_test_utils.datasets.tabular import create_adult_census_data, create_binary_classification_dataset, create_cancer_data, create_diabetes_data, create_iris_data, create_simple_titanic_data
  from rai_test_utils.models.model_utils import create_models_classification
  from rai_test_utils.models.sklearn import create_kneighbors_classifier, create_sklearn_random_forest_regressor, create_titanic_pipeline
  from raiutils.exceptions import UserConfigValidationException
label_desc: Use image node_id 3 for calling a global function with example usage: validate_traversed_tree(tree, tree_dict, max_split_index, feature_names, df, parent_id) without return types