Flatten and unflatten nested Python structures | xAI Interview Question