partial implementation of retracing steps when we ran out of options for edge walk
revert modifications to rotate.{cpp,h}