I need help implementing recursion in a general way - C#