Pergunta de entrevista da empresa Optiver

Tree-related question with recursion