parameters: (self, tree_nodes)
return_statement: return tree_nodes
docstring: Helps cleaning up the tree nodes that get inserted.
docstring_summary: Helps cleaning up the tree nodes that get inserted.
docstring_tokens: Helps cleaning up the tree nodes that get inserted .
function: def _remove_endmarker(self, tree_nodes):
          """
          Helps cleaning up the tree nodes that get inserted.
          """
          last_leaf = tree_nodes[-1].get_last_leaf()
          is_endmarker = last_leaf.type == self.endmarker_type
          self._last_prefix = ''
          if is_endmarker:
              try:
                  separation = last_leaf.prefix.rindex('\n')
              except ValueError:
                  pass
              else:
                  # Remove the whitespace part of the prefix after a newline.
                  # That is not relevant if parentheses were opened. Always parse
                  # until the end of a line.
                  last_leaf.prefix, self._last_prefix = \
                      last_leaf.prefix[:separation + 1], last_leaf.prefix[separation + 1:]
  
          first_leaf = tree_nodes[0].get_first_leaf()
          first_leaf.prefix = self.prefix + first_leaf.prefix
          self.prefix = ''
  
          if is_endmarker:
              self.prefix = last_leaf.prefix
  
              tree_nodes = tree_nodes[:-1]
  
          return tree_nodes
function_tokens: def _remove_endmarker ( self , tree_nodes ) : last_leaf = tree_nodes [ - 1 ] . get_last_leaf ( ) is_endmarker = last_leaf . type == self . endmarker_type self . _last_prefix = '' if is_endmarker : try : separation = last_leaf . prefix . rindex ( '\n' ) except ValueError : pass else : # Remove the whitespace part of the prefix after a newline. # That is not relevant if parentheses were opened. Always parse # until the end of a line. last_leaf . prefix , self . _last_prefix = last_leaf . prefix [ : separation + 1 ] , last_leaf . prefix [ separation + 1 : ] first_leaf = tree_nodes [ 0 ] . get_first_leaf ( ) first_leaf . prefix = self . prefix + first_leaf . prefix self . prefix = '' if is_endmarker : self . prefix = last_leaf . prefix tree_nodes = tree_nodes [ : - 1 ] return tree_nodes