private void BuildNodeDictionary(IotClientNode node, Dictionary <string, List <IotClientNode> > dictionary) { string typeName = node.GetType().Name; List <IotClientNode> nodelist; if (!dictionary.TryGetValue(typeName, out nodelist)) { nodelist = new List <IotClientNode>(); dictionary.Add(typeName, nodelist); } nodelist.Add(node); if (node.Children != null) { foreach (IotClientNode childnode in node.Children) { BuildNodeDictionary(childnode, dictionary); } } }