Raise duplicate key error only when key is accessed
This can be achieved by:
- Creating new
DuplicateKeyobject storing the key and all templates that that key refers to. - Adding
DuplicateKeyto the templates dictionary whenever a template is added to an already existing key. - Raising an error if a
DuplicateKeyis accessed. - Ensure that any entries with
DuplicateKeyare ignores/included when iterating over templates as appropriate.