PLANNER-172 Filtered selection FROM_ENTITY with JIT selection can result in an endless loop.
(cherry picked from commit 1fbfa21da8f99cb28e2a6ebecf581d21cabc030b)
PLANNER-172 Filtered selection FROM_ENTITY with JIT selection can result in an endless loop. => fix testcase
(cherry picked from commit 8538e8b6500249da05ac2594c6a6bd484212d373)