Pregunta de entrevista de Optiver

Tree-related question with recursion