How to select multiple dexterity elements of one type in one dexterity element of another type in Plone 5.1

See the code snippets in this answer: Use case for a listing component - #4 by tiberiuichim