prevent infinite loop in trying to find the optimal path through the cuts.
ray cast between slices to test if connnection is valid

only re-order slices when it's plausible that slice order has changed
more robust slice order inference