Implement flood fill algorithm.