'Cheks if an object holding the same name already exists in the index.
If so, it compares their definition order: the lowest definition order
is kept. If definiton order equal, an error is risen.Item
The method returns the item that should be added after it has decided
which one should be kept.
If the new item has precedence over the New existing one, the
existing is removed for the new to replace it.
:param item:    The new item to check for confict
:param name:    The exiting object name
:return         The retained object'

def manage_conflict(self, item, name):

    if item.is_tpl():
        existing = self.name_to_template[name]
    else:
        existing = self.name_to_item[name]
    existing_prio = getattr(existing, 'definition_order', existing.properties['definition_order'].default)
    item_prio = getattr(item, 'definition_order', item.properties['definition_order'].default)
    if (existing_prio < item_prio):
        return existing
    elif (existing_prio > item_prio):
        pass
    else:
        objcls = getattr(self.inner_class, 'my_type', '[unknown]')
        mesg = ('duplicate    %s    name    %s%s,    using    lastly    defined.    You    may    manually    set    the    definition_order    parameter    to    avoid    this    message.' % (objcls, name, self.get_source(item)))
        item.configuration_warnings.append(mesg)
    if item.is_tpl():
        self.remove_template(existing)
    else:
        self.remove_item(existing)
    return item
