code: def is_valid_tree(beam: List[str]) -> bool:
      paren_stack: List[int] = []
      for i, token in enumerate(beam):
          if len(token) == 0:
              continue
  
          if token[0] == "[":
              paren_stack.append(i)
          elif token[-1] == "]":
              if len(paren_stack) == 0:
                  return False
              paren_stack.pop()
  
      return len(paren_stack) == 0
  
imports: from typing import List, Optional, Tuple
label_desc: Use image node_id 3 for calling a global function with example usage: is_valid_tree(beam) and returns: unknown, False