code: def test_traverse_tree(self):
      c = cursor(
          GenericTuple(
              x=[
                  0,
                  {"a": 1, "b": (2, 3), ("c", "d"): [4, 5]},
                  (100, 200),
                  [3, 4, 5],
              ],
              y=3,
          )
      )
  
      def update_fn(path, value):
          if value == 4:
              return -4
          return value
  
      def cond_fn(path, value):
          return value == 3
  
      with self.assertRaisesRegex(
          TraverseTreeError,
          "Both update_fn and cond_fn are None. Exactly one of them must be"
          " None.",
      ):
          next(_traverse_tree((), c._obj))
      with self.assertRaisesRegex(
          TraverseTreeError,
          "Both update_fn and cond_fn are not None. Exactly one of them must be"
          " not None.",
      ):
          next(
              _traverse_tree(
                  (), c._obj, update_fn=update_fn, cond_fn=cond_fn
              )
          )
  
      (p, v), (p2, v2) = _traverse_tree((), c._obj, update_fn=update_fn)
      self.assertEqual(
          p,
          (
              ("x", AccessType.ATTR),
              (1, AccessType.ITEM),
              (("c", "d"), AccessType.ITEM),
              (0, AccessType.ITEM),
          ),
      )
      self.assertEqual(v, -4)
      self.assertEqual(
          p2,
          (
              ("x", AccessType.ATTR),
              (3, AccessType.ITEM),
              (1, AccessType.ITEM),
          ),
      )
      self.assertEqual(v2, -4)
  
      p, p2, p3 = _traverse_tree((), c._obj, cond_fn=cond_fn)
      self.assertEqual(
          p,
          (
              ("x", AccessType.ATTR),
              (1, AccessType.ITEM),
              ("b", AccessType.ITEM),
              (1, AccessType.ITEM),
          ),
      )
      self.assertEqual(
          p2,
          (
              ("x", AccessType.ATTR),
              (3, AccessType.ITEM),
              (0, AccessType.ITEM),
          ),
      )
      self.assertEqual(p3, (("y", AccessType.ATTR),))
  
imports: import dataclasses
  from typing import Any, NamedTuple
  import jax
  import jax.numpy
  import optax
  from absl.testing import absltest
  import flax
  import flax.linen
  from flax.core import freeze
  from flax.cursor import AccessType, _traverse_tree, cursor
  from flax.errors import CursorFindError, TraverseTreeError
  from flax.training import train_state
label_desc: Use image node_id 4 for calling the CursorTest obj's underlying member method code with example usage: obj.test_traverse_tree() and returns: value, unknown, unknown