When this code was as a copy in getImageElements(), it had a break at this point (as images surely cannot be recursively embedded. Guess not breaking in that case will not be such a performance problem.
Then I am still wondering when text:p could happen to be embedded into each other and if in that case all the text:p should be part of the result?