Pure numeric core of the Bonsai likelihood model. Everything factorises over dimensions, so the methods below operate on D-length vectors and never touch full matrices. This is a direct translation of the functions in bonsai_treeHelpers.py (getLoglikAndGradStarTree, findNodeLtqsGivenLeafs, der2LeafTree, optimiseT3LeafStar, getDerivativesDownstream, ...).