def LocationIterator(obj):
    """Iterate over an object and all of its parents.

    Copied from ``zope.location.LocationIterator``.
    """
    while obj is not None:
        yield obj
        obj = getattr(obj, '__parent__', None)
