<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def visit_statements(self, nodes):
 """Visit a series of nodes in a node body. This function is factored out so that it can be called recursively on statements that are appended or prepended. This allows e.g. a nested expression to prepend a statement, and that statement can prepend a statement again, etc. Args: nodes: A list of statements. Returns: A list of transformed statements. """

    for node in nodes:
      if isinstance(node, gast.AST):
        self.to_prepend.append(deque())
        self.to_append.append(deque())
        node = self.visit(node)
        self.visit_statements(self.to_prepend.pop())
        if isinstance(node, gast.AST):
          self.to_insert[-1].append(node)
        elif node:
          self.to_insert[-1].extend(node)
        self.visit_statements(self.to_append.pop())
      else:
        self.to_insert[-1].append(node)
    return self.to_insert[-1]