Ticket 49278 - GetEffectiveRights gives false-negative
Bug: If geteffective rights was issued for an non existing entry the
mechanism to genrate a template entry no longer worked and no results were
returned.
Fix: Improve the handling in itreating the result set, so that template entries (if
requested) are genereated and are not applied to existing entries.
Also some code cleanup in iterate()
Reviewed by: Thierry, thanks