Pregunta de entrevista de Bloomberg

Write a function that calculates the specific value in a tree.