First stab at the spanning tree logic.