Properties CloneWithParent(Properties parent) { Properties copy = parent != null ? new Properties(parent) : new Properties(); foreach (var pair in dict) { Properties child = pair.Value as Properties; if (child != null) copy.dict.Add(pair.Key, child.CloneWithParent(copy)); else copy.dict.Add(pair.Key, pair.Value); } return copy; }