private void RecursivelyFindPaths(int x, int y) { ICell currentCell = _goalMap._map.GetCell(x, y); if (_visited.Add(currentCell)) { _currentPath.Push(currentCell); List <WeightedPoint> neighbors = _goalMap.GetLowestWeightNeighbors(x, y); if (neighbors != null) { foreach (WeightedPoint neighbor in neighbors) { RecursivelyFindPaths(neighbor.X, neighbor.Y); } } else { // We reached our destination so remove that from the list of visited cells in case there is another path here. _visited.Remove(currentCell); _paths.Add(new Path(_currentPath.Reverse())); } _currentPath.Pop(); } }