private IEnumerable <Identity> GetGroupTopicIdsAndDescendants(Identity groupId) { var topics = topicByGroup.GetTopicIds(groupId); foreach (var childTopicId in topics) { yield return(childTopicId); } var children = childGroupsOfGroup.GetChildrenIds(groupId); foreach (var child in children) { var grandChildren = GetGroupTopicIdsAndDescendants(child); foreach (var grandChild in grandChildren) { yield return(grandChild); } } }