It's a red-green tree. Your task is to invert it in O(n) operations.