Flatten and unflatten nested Python structures | xAI Coding Question