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