public void ResolveKeyPath(KeyPath keyPath, int depth, List <KeyPath> accumulator, KeyPath currentPartialKeyPath) { if (!keyPath.Matches(Name, depth)) { return; } if (!"__container".Equals(Name)) { currentPartialKeyPath = currentPartialKeyPath.AddKey(Name); if (keyPath.FullyResolvesTo(Name, depth)) { accumulator.Add(currentPartialKeyPath.Resolve(this)); } } if (keyPath.PropagateToChildren(Name, depth)) { int newDepth = depth + keyPath.IncrementDepthBy(Name, depth); for (int i = 0; i < _contents.Count; i++) { var content = _contents[i]; if (content is IKeyPathElement element) { element.ResolveKeyPath(keyPath, newDepth, accumulator, currentPartialKeyPath); } } } }