code: def reconstruct_tree(
      tree,
      sequence,
      transition_scheme=TransitionScheme.IN_ORDER,
      unary_limit=UNARY_LIMIT,
      reverse=False,
  ):
      """
      Starting from a tree and a list of transitions, build the tree caused by the transitions
      """
      model = SimpleModel(
          transition_scheme=transition_scheme,
          unary_limit=unary_limit,
          reverse_sentence=reverse,
      )
      states = model.initial_state_from_gold_trees([tree])
      assert (len(states)) == 1
      assert states[0].num_transitions() == 0
  
      # TODO: could fold this into parse_sentences (similar to verify_transitions in trainer.py)
      for idx, t in enumerate(sequence):
          assert t.is_legal(
              states[0], model
          ), "Transition {} not legal at step {} in sequence {}".format(
              t, idx, sequence
          )
          states = parse_transitions.bulk_apply(model, states, [t])
  
      result_tree = states[0].constituents.value
      if reverse:
          result_tree = result_tree.reverse()
      return result_tree
  
imports: import pytest
  from stanza.models.constituency import parse_transitions
  from stanza.models.constituency import transition_sequence
  from stanza.models.constituency import tree_reader
  from stanza.models.constituency.base_model import SimpleModel, UNARY_LIMIT
  from stanza.models.constituency.parse_transitions import *
  from stanza.tests import *
  from stanza.tests.constituency.test_parse_tree import CHINESE_LONG_LIST_TREE
label_desc: Use image node_id 1 for calling a global function with example usage: reconstruct_tree(tree, sequence, transition_scheme, unary_limit, reverse) and returns: result_tree