<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def append_block(self, node, reverse=False):
 """Append a statement to the current block. Args: node: The statement to prepend. reverse: When called multiple times, this flag determines whether the statement should be prepended or appended to the already inserted statements. Raises: ValueError: If the given node is not a statement. """

    if not isinstance(node, grammar.STATEMENTS):
      raise ValueError
    if reverse:
      self.to_append_block[-1].appendleft(node)
    else:
      self.to_append_block[-1].append(node)