<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _TrimNode(node, index, depth, flags):
 """ Internal helper method to trim a node. Args: node (MerkleTreeNode):
 index (int):
 flag index. depth (int):
 node tree depth to start trim from. flags (bytearray):
 of left/right pairs. 1 byte for the left node, 1 byte for the right node. 00 to erase, 11 to keep. Will keep the node if either left or right is not-0 """

        if depth == 1 or node.LeftChild is None:
            return

        if depth == 2:
            if not flags[index * 2] and not flags[index * 2 + 1]:
                node.LeftChild = None
                node.RightChild = None

        else:

            MerkleTree._TrimNode(node.LeftChild, index * 2, depth - 1, flags)
            MerkleTree._TrimNode(node.RightChild, index * 2, depth - 1, flags)

            if node.LeftChild.LeftChild is None and node.RightChild.RightChild is None:
                node.LeftChild = None
                node.RightChild = None