WHERE block some fixes

Signed-off-by: Aleksey Snisar <osni@isd.dp.ua>
Add recursive && some refactoring

Signed-off-by: Aleksey Snisar <osni@isd.dp.ua>