Branches of a Tree: Taking Derivatives of Programs with Discrete and Branching Randomness in High Energy Physics