How to implement flood fill to detect enclose space?

lol I got a stack overflow thing.