Find Leaf Nodes in a Tree for which the Sum of the Root Path Matches a Target Value

I did not find this problem on a website. The requirements came up during a conversation with a software engineer. I wish I could have taken some notes but I did not. The problem had a single diagram of a sample general tree and there was no class definition for the nodes.

We are given a general binary three in which a node may have none, one or more children.
In addition each node has an integer value.
The values may repeat.

Our tasks if to come up with a function 
that will display the leaf nodes 
for which the sum of all node values in the path from the root 
add up to a defined target.

As far as I can remember that was the gist of the problem. Continue reading “Find Leaf Nodes in a Tree for which the Sum of the Root Path Matches a Target Value”