class_docstr: A data structure to represent a parse tree
class_docstr_tok: ["A","data","structure","to","represent","a","parse","tree"]
docstr: Visit the tree in a preorder order
  
  Applies the given functions to each node.
  internal: if not None, applies this function to each non-leaf, non-preterminal node
  preterminal: if not None, applies this functiion to each preterminal
  leaf: if not None, applies this function to each leaf
  
  The functions should *not* destructively alter the trees.
  There is no attempt to interpret the results of calling these functions.
  Rather, you can use visit_preorder to collect stats on trees, etc.
docstr_tok: ["Visit","the","tree","in","a","preorder","order","Applies","the","given","functions","to","each","node",".","internal",":","if","not","None",",","applies","this","function","to","each","non-leaf",",","non-preterminal","node","preterminal",":","if","not","None",",","applies","this","functiion","to","each","preterminal","leaf",":","if","not","None",",","applies","this","function","to","each","leaf","The","functions","should","*","not","*","destructively","alter","the","trees",".","There","is","no","attempt","to","interpret","the","results","of","calling","these","functions",".","Rather",",","you","can","use","visit_preorder","to","collect","stats","on","trees",",","etc","."]
code: def visit_preorder(self, internal=None, preterminal=None, leaf=None):
      """
      Visit the tree in a preorder order
  
      Applies the given functions to each node.
      internal: if not None, applies this function to each non-leaf, non-preterminal node
      preterminal: if not None, applies this functiion to each preterminal
      leaf: if not None, applies this function to each leaf
  
      The functions should *not* destructively alter the trees.
      There is no attempt to interpret the results of calling these functions.
      Rather, you can use visit_preorder to collect stats on trees, etc.
      """
      if self.is_leaf():
          if leaf:
              leaf(self)
      elif self.is_preterminal():
          if preterminal:
              preterminal(self)
      else:
          if internal:
              internal(self)
      for child in self.children:
          child.visit_preorder(internal, preterminal, leaf)
  
imports: from collections import deque, Counter
  from enum import Enum
  from io import StringIO
  import itertools
  import re
  import warnings
  from stanza.models.common.stanza_object import StanzaObject
label_desc: Use image node_id 13 for calling the Tree obj's underlying member method code with example usage: obj.visit_preorder(internal, preterminal, leaf) without return types