Calculating the probability of a tree