## BJP4 Exercise 17.3: depthSum

Language/Type: Java binary trees implementing IntTree
Author: Robert Baxter (on 2016/09/08)

Write a method `depthSum` that returns the sum of the values stored in a binary tree of integers weighted by the depth of each value. You should return the value at the `overallRoot` plus 2 times the values stored at the next level of the tree plus 3 times the values stored at the next level of the tree plus 4 times the values stored at the next level of the tree and so on. For example, in the tree below:

```          +---+
| 9 |
+---+
/     \
+---+     +---+
| 7 |     | 6 |
+---+     +---+
/     \         \
+---+     +---+     +---+
| 3 |     | 2 |     | 4 |
+---+     +---+     +---+
/               \
+---+               +---+
| 5 |               | 2 |
+---+               +---+
```

The sum would be computed as:

```1 * 9 + 2 * (7 + 6) + 3 * (3 + 2 + 4) + 4 * (5 + 2) = 90
```

Assume that you are adding this method to the `IntTree` class as defined below:

```public class IntTree {
private IntTreeNode overallRoot;
...
}
```