'Find the parent for the given import item
@param item: the import item
@return: a tuple (id, uid, item) for the parent'

@classmethod
def parent(cls, item):

    parent_id = parent_uid = parent_item = None
    is_key = (lambda fk, name: ((fk == name) or (isinstance(fk, (tuple, list)) and (fk[1] == name))))
    all_items = item.job.items
    for (uid, link_item) in all_items.items():
        if (link_item.tablename == 'org_organisation_branch'):
            references = link_item.references
            parent = branch = None
            for reference in references:
                fk = reference.field
                if is_key(fk, 'branch_id'):
                    branch = reference.entry
                elif is_key(fk, 'organisation_id'):
                    parent = reference.entry
                if (parent and branch):
                    break
            if (parent and branch and (branch.item_id == item.item_id)):
                parent_id = parent.id
                parent_uid = parent.uid
                parent_item = all_items.get(parent.item_id)
                break
    return (parent_id, parent_uid, parent_item)
