Gradle-3127: cleanup walked shouldRunAfter edges after leaving the branch

+review REVIEW-5213