private void SetIndexesForConfigGroupCollectionRecursively(ConfigurationGroupCollection configGroupCollection) { for (int i = 0; i < configGroupCollection.Count; i++) { var configGroup = configGroupCollection[i]; configGroup.Index = i; SetIndexesForConfigGroupElementRecursively(configGroup); } }