code: def _check_policy_tree(
      policy_tree, config, depth=0, is_serialized=False
  ):
      if is_serialized:
          if policy_tree.leaf:
              assert isinstance(policy_tree, CausalPolicyTreeLeaf)
              assert hasattr(policy_tree, "treatment")
              assert hasattr(policy_tree, "n_samples")
          else:
              assert isinstance(policy_tree, CausalPolicyTreeInternal)
              assert isinstance(policy_tree.feature, str)
              assert isinstance(policy_tree.right_comparison, str)
              assert isinstance(
                  policy_tree.comparison_value, (str, int, float)
              )
              _check_policy_tree(
                  policy_tree.left,
                  config,
                  depth=depth + 1,
                  is_serialized=is_serialized,
              )
              _check_policy_tree(
                  policy_tree.right,
                  config,
                  depth=depth + 1,
                  is_serialized=is_serialized,
              )
      else:
          assert depth <= config.max_tree_depth
  
          assert isinstance(policy_tree, dict)
          if policy_tree["leaf"]:
              assert "treatment" in policy_tree
              assert "n_samples" in policy_tree
          else:
              assert isinstance(policy_tree["feature"], str)
              assert isinstance(policy_tree["threshold"], float)
              _check_policy_tree(
                  policy_tree["left"],
                  config,
                  depth=depth + 1,
                  is_serialized=is_serialized,
              )
              _check_policy_tree(
                  policy_tree["right"],
                  config,
                  depth=depth + 1,
                  is_serialized=is_serialized,
              )
  
imports: import numpy
  import pandas
  import pytest
  from econml.solutions.causal_analysis._causal_analysis import CausalAnalysis
  from raiutils.exceptions import UserConfigValidationException
  from raiutils.models import ModelTask
  from responsibleai._interfaces import CausalConfig, CausalData, CausalPolicy, CausalPolicyGains, CausalPolicyTreeInternal, CausalPolicyTreeLeaf
  from responsibleai._internal.constants import CausalManagerKeys, ListProperties, ManagerNames
  from responsibleai._tools.causal.causal_result import CausalResult
label_desc: Use image node_id 14 for calling a global function with example usage: _check_policy_tree(policy_tree, config, depth, is_serialized) without return types