class_docstr: ExecutionPlan, collection of operations.
docstr: Build the operation tree from the string representation
docstr_tok: ["Build","the","operation","tree","from","the","string","representation"]
code: def _operation_tree(self):
      """Build the operation tree from the string representation"""
  
      # initial state
      i = 0
      level = 0
      stack = []
      current = None
  
      def _create_operation(args):
          profile_stats = None
          name = args[0].strip()
          args.pop(0)
          if len(args) > 0 and "Records produced" in args[-1]:
              records_produced = int(
                  re.search("Records produced: (\\d+)", args[-1]).group(
                      1
                  )
              )
              execution_time = float(
                  re.search(
                      "Execution time: (\\d+.\\d+) ms", args[-1]
                  ).group(1)
              )
              profile_stats = ProfileStats(
                  records_produced, execution_time
              )
              args.pop(-1)
          return Operation(
              name,
              None if len(args) == 0 else args[0].strip(),
              profile_stats,
          )
  
      # iterate plan operations
      while i < len(self.plan):
          current_op = self.plan[i]
          op_level = current_op.count("    ")
          if op_level == level:
              # if the operation level equal to the current level
              # set the current operation and move next
              child = _create_operation(current_op.split("|"))
              if current:
                  current = stack.pop()
                  current.append_child(child)
              current = child
              i += 1
          elif op_level == level + 1:
              # if the operation is child of the current operation
              # add it as child and set as current operation
              child = _create_operation(current_op.split("|"))
              current.append_child(child)
              stack.append(current)
              current = child
              level += 1
              i += 1
          elif op_level < level:
              # if the operation is not child of current operation
              # go back to it's parent operation
              levels_back = level - op_level + 1
              for _ in range(levels_back):
                  current = stack.pop()
              level -= levels_back
          else:
              raise Exception("corrupted plan")
      return stack[0]
  
file_path: catboost/contrib/python/redis/py3/redis/commands/graph/execution_plan.py
imports: import re
label_desc: Use image node_id 6 for calling the ExecutionPlan obj's underlying member method code with example usage: obj._operation_tree() and returns: stack, Operation