Accord.Controls.DenavitHartenbergViewer.GetAllModels C# (CSharp) Method

GetAllModels() private method

Makes a list of all the models contained on a ModelCombinator. This function is recursive.
private GetAllModels ( DenavitHartenbergNode model, List models ) : List
model DenavitHartenbergNode /// ModelCombinator model in which to extract all the models.
models List /// List of already extracted models. It accumulates all the /// models at each call of this function.
return List
        private List<DenavitHartenbergModel> GetAllModels(DenavitHartenbergNode model,
            List<DenavitHartenbergModel> models)
        {
            // If it's the first call
            if (models == null)
            {
                // Create the models list
                models = new List<DenavitHartenbergModel>();
            }

            // Add the model contained in the ModelCombinator
            models.Add(model.Model);

            // For all the children of the ModelCombinator
            foreach (DenavitHartenbergNode child in model.Children)
            {
                // Execute recursively this function 
                models = GetAllModels(child, models);
            }

            // Return the models list
            return models;
        }