Refactor on connected region search to work standalone

Signed-off-by: Luiz Carlos Cavalcanti <cavalcanti.luiz@gmail.com>