<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def end_container(self, header_buf):
 """Add a node containing the container's header to the current subtree. This node will be added as the leftmost leaf of the subtree that was started by the matching call to start_container. Args: header_buf (bytearray):
 bytearray containing the container header. """

        if not self.__container_nodes:
            raise ValueError("Attempted to end container with none active.")
        # Header needs to be the first node visited on this subtree.
        self.__container_node.add_leaf(_Node(header_buf))
        self.__container_node = self.__container_nodes.pop()
        parent_container_length = self.__container_lengths.pop()
        self.current_container_length = \
            parent_container_length + self.current_container_length + len(header_buf)