[ORC] Add WaitingOnGraph::visitWithRemoval, refactor some loops. (#185001)
visitWithRemoval visits the elements of a vector performing a
swap-and-pop to remove any for which the visitor returns true.
Use this to refactor some loops in WaitingOnGraph that used this idiom.