Jane Street interview question

tree related class design question