private static void ProcessVariables(Activity parent, IList <Variable> variables, ActivityCollectionType collectionType, bool addChildren, ref ActivityLocationReferenceEnvironment environment, ref int nextEnvironmentId, ref ChildActivity nextActivity, ref Stack <ChildActivity> activitiesRemaining, ref IList <ValidationError> validationErrors)
 {
     if (variables.Count > 0)
     {
         if (environment == null)
         {
             environment = new ActivityLocationReferenceEnvironment(parent.GetParentEnvironment());
         }
         for (int i = 0; i < variables.Count; i++)
         {
             Variable locationReference = variables[i];
             if (locationReference.InitializeRelationship(parent, collectionType == ActivityCollectionType.Public, ref validationErrors))
             {
                 locationReference.Id = nextEnvironmentId;
                 nextEnvironmentId++;
                 environment.Declare(locationReference, locationReference.Owner, ref validationErrors);
                 if (addChildren)
                 {
                     SetupForProcessing(locationReference, ref nextActivity, ref activitiesRemaining);
                 }
             }
         }
     }
 }