An efficient solution to Hidden Markov Models on trees with coupled branches