/// <summary>
        /// Method used to add a element into a sorted collection without destroying the sorting order.
        /// </summary>
        /// <param name="typeIndex">Index in the collection at which the link type's elements start.</param>
        /// <param name="collection">Sorted collection to add the new view models to.</param>
        /// <param name="link">Embedding relationship including the model element as the child (target).</param>
        /// <param name="c">View model representing the model element to be added to the collection.</param>
        protected virtual void InsertElement(int typeIndex, DslEditorTreeViewModel::BaseModelElementTreeViewModel parent, System.Collections.ObjectModel.ObservableCollection <DslEditorTreeViewModel::BaseModelElementTreeViewModel> collection, DslModeling::ElementLink link, DslEditorTreeViewModel::BaseModelElementTreeViewModel c)
        {
            System.Collections.ObjectModel.ReadOnlyCollection <DslModeling::ElementLink> lllinks = DslModeling::DomainRoleInfo.GetElementLinks <DslModeling::ElementLink>(parent.Element, DslEditorModeling::DomainModelElement.GetSourceDomainRole(link.GetDomainRelationship()).Id);
            int indexOfLink = lllinks.IndexOf(link) + typeIndex;

            if (indexOfLink >= collection.Count)
            {
                collection.Add(c);
            }
            else
            {
                collection.Insert(indexOfLink, c);
            }
        }
        /// <summary>
        /// Method used to add a element into a sorted collection without destroying the sorting order.
        /// </summary>
        /// <param name="collection">Sorted collection to add the new view models to.</param>
        /// <param name="link">Embedding relationship including the model element as the child (target).</param>
        /// <param name="c">View model representing the model element to be added to the collection.</param>
        public override void InsertElement(DslEditorTreeViewModel::BaseModelElementTreeViewModel parent, System.Collections.ObjectModel.ObservableCollection <DslEditorTreeViewModel::BaseModelElementTreeViewModel> collection, DslModeling::ElementLink link, DslEditorTreeViewModel::BaseModelElementTreeViewModel c)
        {
            if (parent.ElementLinkOrder.Count <= 1)
            {
                InsertElement(0, parent, collection, link, c);
            }
            else
            {
                int index = 0;
                System.Collections.Generic.List <System.Guid> typesBeforeCurrent = new System.Collections.Generic.List <System.Guid>();
                System.Guid currentType = c.ElementLinkDomainClassId;
                for (int i = 0; i < parent.ElementLinkOrder.Count; i++)
                {
                    if (parent.ElementLinkOrder[i] == currentType)
                    {
                        index = i;
                        break;
                    }
                    else
                    {
                        typesBeforeCurrent.Add(parent.ElementLinkOrder[i]);
                    }
                }

                if (index > 0)
                {
                    for (int i = 0; i < collection.Count; i++)
                    {
                        if (typesBeforeCurrent.Contains(collection[i].ElementLinkDomainClassId))
                        {
                            continue;
                        }

                        InsertElement(i, parent, collection, link, c);
                        return;
                    }
                    InsertElement(collection.Count, parent, collection, link, c);
                    return;
                }
                InsertElement(index, parent, collection, link, c);
            }
        }