Break a loop that shows up with Keyed Unification

Without keyed unification, `rewrite` inferred that a particular endpoint
of a particular path was `((1 ∘ x ∘ 1) x2)`.  However, in the goal, this
endpoint was passed as (the judgmentally equivalent) `x2`.  So after
`rewrite` finished filling in its holes, it couldn't find the subterm
anymore, breaking the loop.  With keyed unification, it can find the
subterm, so the rewrite loops.
Factor out transport_to_ap
Merge pull request #554 from JasonGross/break-keyed-unification-loop

Break a loop that shows up with Keyed Unification