Implement type AST and infer generics | OpenAI Interview Question