Not all code paths return a value?

I’m trying to add all the neighbors to a list that are within a certain number of movements from the starting position but I can’t seem to find out why not all code paths aren’t returning a value:

public List SetNeighbours(Node currentN, ListopenS,int movementP){
		foreach (Node neighbour in GetNeighbours(currentN)) {
			if (HighlightT.Contains (neighbour)) {
				continue;
			}
		
			int newMovementCostToNeighbour = currentN.gCost + Astar.GetComponent<PathFinding> ().GetDistance (currentN, neighbour) + neighbour.movementCost;
			int _MPL=MP-newMovementCostToNeighbour;
			if (newMovementCostToNeighbour <= _MPL) {
				neighbour.gCost = newMovementCostToNeighbour;
				neighbour.MPU=newMovementCostToNeighbour;
				neighbour.MPL=_MPL;
				neighbour.parent = currentN;
			
				if (!openS.Contains (neighbour))
					openS.Add (neighbour);
				return openS;

			}
		}
	}

if (newMOvementCostToNeighbour <= _MPL) {
// your stuff
return openS;
}

// if it falls through to here, nothing is being returned

When that condition is false there is no return executed so the function doesn’t return anything. Also when the foreach loop completes there is no return there either.

I believe you need to move return openS after the foreach. If you’re having trouble understanding these concepts, I would suggest spending some time with some programming tutorials.