Pergunta de entrevista da empresa Datadog

sum all the values associated to leaf nodes in a tree