Write a program in Prolog that traverses a terrarium in depth and calculate the sum of each branch from the root to a leaf. The resulting sums must be returned in a list in the order in verse followed by walking the tree.
Write a program in Prolog that traverses a terrarium in depth and calculate the sum of each branch from the root to a leaf. The resulting sums must be returned in a list in the order in verse followed by walking the tree.