If you're using a tilemap, it's easy. This is the flood fill I use to check for closed-off areas in a procedural dungeon. I wouldn't use recursion, as it's a pretty simple algorithm anyway:
var looked = {}
var q = []
var curr = Vector2(0, 0)
# Pick a random, walkable point.
while not G.WALK[G.map_tiles.get_cellv(curr)]:
curr = Vector2(randi() % MAP_SIZE_X, randi() % MAP_SIZE_Y)
q.push_back(curr)
while not q.empty():
curr = q.pop_front()
looked[curr] = true
for dy in 3:
for dx in 3:
var l = Vector2(curr.x + dx - 1, curr.y + dy - 1)
if (not looked.has(l)) and G.WALK[G.map_tiles.get_cellv(l)]:
looked[l] = true
q.push_back(l)