public static List <BACnetObjectTypeGroup> OrganizeBacnetObjects(List <KeyValuePair <BacnetObjectId, BACnetObject> > bacnetObjects) //used from parent BACnet device
        {
            List <String> uniqueTypeStrings = new List <String>();
            List <BACnetObjectTypeGroup> bacnetObjectTypeGroups = new List <BACnetObjectTypeGroup>();


            foreach (var kvp in bacnetObjects)
            {
                String objTypeString = kvp.Key.typeString;
                if (!uniqueTypeStrings.Contains(objTypeString))
                {
                    uniqueTypeStrings.Add(objTypeString);        //should be in order already since we sorted BacnetObjects by type
                    bacnetObjectTypeGroups.Add(new BACnetObjectTypeGroup(objTypeString));
                }
            }


            foreach (var kvp in bacnetObjects)
            {
                var typeString            = kvp.Key.typeString;
                var bacnetObject          = kvp.Value;
                var bacnetObjectTypeGroup = BACnetObjectTypeGroup.GetByTypeString(bacnetObjectTypeGroups, typeString);
                bacnetObjectTypeGroup.AddObject(bacnetObject);
            }

            return(bacnetObjectTypeGroups);
        }
        //only need to define this function for lazy loaded nodes.
        public List <BACnetTreeNode> GetChildNodes()
        {
            if (!ObjectsFetched)
            {
                GetObjects();   //when this node is expanded, need to know all of its objects
            }
            var bacnetObjectTypeGroups = BACnetObjectTypeGroup.OrganizeBacnetObjects(BacnetObjects);


            var childNodes = new List <BACnetTreeNode>();

            foreach (var bacnetObjectTypeGroup in bacnetObjectTypeGroups)
            {
                childNodes.Add(bacnetObjectTypeGroup.GetTreeNode());
            }

            return(childNodes);
        }