'Find loop in dependencies.
For now, used with the following attributes :
:(self, parents):
host dependencies from host object
:(host_name, dependent_host_name):            host dependencies from hostdependencies object
:(service_description, dependent_service_description):
service dependencies from servicedependencies object'

def no_loop_in_parents(self, attr1, attr2, templates=False):

    r = True
    parents = Graph()
    elts_lst = self
    if templates:
        elts_lst = self.templates.values()
    for item in elts_lst:
        if (attr1 == 'self'):
            obj = item
        else:
            obj = getattr(item, attr1, None)
        if (obj is not None):
            if isinstance(obj, list):
                for sobj in obj:
                    parents.add_node(sobj)
            else:
                parents.add_node(obj)
    for item in elts_lst:
        if (attr1 == 'self'):
            obj1 = item
        else:
            obj1 = getattr(item, attr1, None)
        obj2 = getattr(item, attr2, None)
        if (obj2 is not None):
            if isinstance(obj2, list):
                for sobj2 in obj2:
                    if isinstance(obj1, list):
                        for sobj1 in obj1:
                            parents.add_edge(sobj1, sobj2)
                    else:
                        parents.add_edge(obj1, sobj2)
            elif isinstance(obj1, list):
                for sobj1 in obj1:
                    parents.add_edge(sobj1, obj2)
            else:
                parents.add_edge(obj1, obj2)
    items_in_loops = parents.loop_check()
    for item in items_in_loops:
        logger.error("The    %s    object    '%s'        is    part    of    a    circular    parent/child    chain!", item.my_type, item.get_name())
        r = False
    return r
