Efficient Principled Learning of Thin Junction Trees