I’ve used the method described in my previous post and I believe I’ve achieved the desired result.
https://jsfiddle.net/prisoner849/Lmrh25js/
Checked 4 nearest elements around current and rebuild box geometry’s index in accordance to the results of checks.