'Verifies that there is no loop in a hierarchical structure of records,
by following the parent relationship using the **parent** field until a
loop is detected or until a top-level record is found.
:param parent: optional parent field name (default: ``self._parent_name``)
:return: **True** if no loop was found, **False** otherwise.'

@api.multi
def _check_recursion(self, parent=None):

    if (not parent):
        parent = self._parent_name
    cr = self._cr
    query = ('SELECT    "%s"    FROM    "%s"    WHERE    id    =    %%s' % (parent, self._table))
    for id in self.ids:
        current_id = id
        while current_id:
            cr.execute(query, (current_id,))
            result = cr.fetchone()
            current_id = (result[0] if result else None)
            if (current_id == id):
                return False
    return True
