The method by which we update intermediate_results here could be improved by doing it automatically, within the calculation. However, to do that, we would need to assume that the first component passed to `AlgorithmInput` is the parent component.
<h2>A comment on intermediate_results<h2>
For the trust-weighted histogram algorithm the `intermediate_results` are really the same thing as the output. Therefore it is possible that these could be folded together and not require the extra variable. However, it is convenient to use this variable for differentiating between nodes that have not yet been binned because they are the first nodes in the calculation, and those that have. Those that have then simply use the `intermediate_results` and those that haven't need to undergo a binning process (done in `GetHForAllLeafNodes`). For the straight average algorithm, however, the output and the `intermediate_results` are completely different.
The method by which we update `intermediate_results` here could be improved by doing it automatically, within the calculation. We refrained from that, however, in recognition that doing so is the province of the server code, the one responsible for understanding the tree's overall configuration and how results should pass between the nodes.
Also the `intermediate_results` are really for the parent components of each sub-group. This just happens to be the first component passed to AlgorithmInput in the cases above but there is no mechanism to enforce that. We could, of course, have just set all the components' `intermediate_results` to be the same as that of the parent component and things would have worked. But this seems like a shortcut that might inadvertently cause problems later and be hard to detect. It seems like a better practice to set variables explicitly at the point where we know we will need them for a subsequent calculation.