def _parent(entity):
    """Return the first encountered parent which is an ArchiveUnit"""
    while entity.cw_etype not in ('SEDAArchiveTransfer', 'SEDAArchiveUnit',
        'SEDABinaryDataObject', 'SEDAPhysicalDataObject'):
        entity = entity.cw_adapt_to('IContained').parent
    return entity
