docs: def clean_whitespace(self, tree):
          """
          Cleans up whitespace around block open and close tags if they are the
          only thing on the line
  
          :param tree:
              The AST - will be modified in place
          """
  
          pointer = 0
          end = len(tree)
  
          while pointer < end:
              piece = tree[pointer]
              if piece[0] == 'block':
                  child_tree = piece[3]
  
                  # Look at open tag, if the only other thing on the line is whitespace
                  # then delete it so we don't introduce extra newlines to the output
                  open_pre_whitespace = False
                  open_pre_content = True
                  if pointer > 1 and tree[pointer - 1][0] == 'whitespace' and (tree[pointer - 2][0] == 'newline' or tree[pointer - 2] == 'template'):
                      open_pre_whitespace = True
                      open_pre_content = False
                  elif pointer > 0 and (tree[pointer - 1][0] == 'newline' or tree[pointer - 1] == 'template'):
                      open_pre_content = False
  
                  open_post_whitespace = False
                  open_post_content = True
                  child_len = len(child_tree)
                  if child_len > 2 and child_tree[1][0] == 'whitespace' and child_tree[2][0] == 'newline':
                      open_post_whitespace = True
                      open_post_content = False
                  elif child_len > 1 and child_tree[1][0] == 'newline':
                      open_post_content = False
  
                  if not open_pre_content and not open_post_content:
                      if open_pre_whitespace:
                          tree.pop(pointer - 1)
                          pointer -= 1
                          end -= 1
                      if open_post_whitespace:
                          child_tree.pop(1)
                      child_tree.pop(1)  # trailing newline
  
                  # Do the same thing, but for the close tag
                  close_pre_whitespace = False
                  close_pre_content = True
                  child_len = len(child_tree)
                  if child_len > 2 and child_tree[child_len - 1][0] == 'whitespace' and child_tree[child_len - 2][0] == 'newline':
                      close_pre_whitespace = True
                      close_pre_content = False
                  elif child_len > 1 and child_tree[child_len - 1][0] == 'newline':
                      close_pre_content = False
  
                  close_post_whitespace = False
                  close_post_content = True
                  tree_len = len(tree)
                  if tree_len > pointer + 2 and tree[pointer + 1][0] == 'whitespace' and tree[pointer + 2][0] == 'newline':
                      close_post_whitespace = True
                      close_post_content = False
                  elif tree_len == pointer + 2 and tree[pointer + 1][0] == 'whitespace':
                      close_post_whitespace = True
                      close_post_content = False
                  elif tree_len > pointer + 1 and tree[pointer + 1][0] == 'newline':
                      close_post_content = False
                  elif tree_len == pointer + 1:
                      close_post_content = False
  
                  if not close_pre_content and not close_post_content:
                      if close_pre_whitespace:
                          child_tree.pop()
                      child_tree.pop()  # preceeding newline
                      if close_post_whitespace:
                          tree.pop(pointer + 1)
                          end -= 1
  
                  self.clean_whitespace(child_tree)
  
              pointer += 1