code: def flip(self):
          
  
          left = self.left._replace(red=not self.left.red)
          right = self.right._replace(red=not self.right.red)
          top = self._replace(left=left, right=right, red=not self.red)
          return top
docs: Flip colors of a node and its children.