public IEnumerable <BSPTree> GetLeaves() { if (this.IsLeafNode) { return(Enumerables.Single(this)); } var firstLeaves = this.FirstChild.GetLeaves(); var secondLeaves = this.SecondChild.GetLeaves(); return(firstLeaves.Concat(secondLeaves)); }