Automatically flatten classes extending BaseModel