private static IEnumerable <string> GetOutboundActivityPathInternal(this WorkflowExecutionContext workflowExecutionContext, string activityId, string startingPointActivityId) { foreach (var connection in workflowExecutionContext.GetOutboundConnections(activityId)) { // Circuit breaker: Detect workflows that implement repeating flows to prevent an infinite loop here. if (connection.Target.Activity.Id == startingPointActivityId) { yield break; } yield return(connection.Target.Activity.Id !); foreach (var childActivityId in workflowExecutionContext .GetOutboundActivityPathInternal(connection.Target.Activity.Id !, startingPointActivityId) .Distinct()) { yield return(childActivityId); } } }