Can I simplify this recursive grid search? I've written a recursive method for fetching grid neighbours in a symmetrical 2-dimensional grid, the problem is that I've found myself duplicating the code more or less into an overload to prevent my list from re-initializing everytime the method calls on itself.

I'm guessing there are ways to get around this that doesn't involve code duplication. Any help is appreciated.

public List&lt;Cell&lt;int&gt;&gt; GetNeighbours(Cell&lt;int&gt; cell, Direction direction, int neighboursToGet)
        {
            var neighbours = new List&lt;Cell&lt;int&gt;&gt;();

            if (neighboursToGet &gt; 0)
            {
                int x = 0;
                int y = 0;
                Cell&lt;int&gt; neighbour;

                switch (direction)
                {
                    case Direction.Left:
                        x = -1;
                        break;
                    case Direction.Right:
                        x = 1;
                        break;
                    case Direction.Up:
                        y = -1;
                        break;
                    case Direction.Down:
                        y = 1;
                        break;
                }

                neighbour = cells[cell.Position.Row + y, cell.Position.Column + x];
                neighbours.Add(neighbour);
                GetNeighbours(neighbour, direction, neighboursToGet - 1, neighbours);
            }             
            return neighbours;
        }

        public List&lt;Cell&lt;int&gt;&gt; GetNeighbours(Cell&lt;int&gt; cell, Direction direction, int neighboursToGet, List&lt;Cell&lt;int&gt;&gt; neighbours)
        {
            if (neighboursToGet &gt; 0)
            {
                int x = 0;
                int y = 0;
                Cell&lt;int&gt; neighbour;

                switch (direction)
                {
                    case Direction.Left:
                        x = -1;
                        break;
                    case Direction.Right:
                        x = 1;
                        break;
                    case Direction.Up:
                        y = -1;
                        break;
                    case Direction.Down:
                        y = 1;
                        break;
                }

                neighbour = cells[cell.Position.Row + y, cell.Position.Column + x];
                neighbours.Add(neighbour);
                GetNeighbours(neighbour, direction, neighboursToGet - 1, neighbours);
            }
            return neighbours;
        }
It seems to me that most of the body of the first GetNeighbours is extraneous. Wouldn't this be enough ?

public List&lt;Cell&lt;int&gt;&gt; GetNeighbours(Cell&lt;int&gt; cell, Direction direction, int neighboursToGet)
{
    var neighbours = new List&lt;Cell&lt;int&gt;&gt;();

    GetNeighbours(cell, direction, neighboursToGet, neighbours);

    return neighbours;
}


Also, it is redundant to accept neighbours as a read/write parameter and to return it. However, if you are going to do it, you could as well write:

public List&lt;Cell&lt;int&gt;&gt; GetNeighbours(Cell&lt;int&gt; cell, Direction direction, int neighboursToGet)
{
    return GetNeighbours(cell, direction, neighboursToGet, new List&lt;Cell&lt;int&gt;&gt;());
}