Get the datacenter to whom an object belongs

def get_datacenter(content, obj):
    '''
    Get the datacenter to whom an object belongs
    '''
    datacenters = content.rootFolder.childEntity
    for d in datacenters:
        dch = get_all(content, d, type(obj))
        if dch is not None and obj in dch:
            return d