1) test also against null; to avoid an infinite loop, if something goes wrong
2) comment please this logic; why do we need it?

UPDATE: in fact, the initial version should work. It must be something wrong with the way we work with contentToGlobal & co. And if we get it working, couldn't we put this logic in the parent class? so that we don't have this class?