Uprooting and Rerooting Higher-Order Graphical Models