private void Populate(TreeListView treeView, IEnumerable objects, IModelFilter filter) { if (objects == null) { return; } foreach (var obj in objects) { if (treeView.ChildrenGetter != null) { Populate(treeView, treeView.ChildrenGetter(obj), filter); } if (!filter.Filter(obj)) { continue; } var matched = obj; while (matched != null) { _objects.Add(matched); matched = (matched as IDataObjectChild)?.Parent; } } }