

def find_ref_chain(obj, predicate, max_depth=20, extra_ignore=()):
    'Find a shortest chain of references leading from obj.\n\n    The end of the chain will be some object that matches your predicate.\n\n    ``predicate`` is a function taking one argument and returning a boolean.\n\n    ``max_depth`` limits the search depth.\n\n    ``extra_ignore`` can be a list of object IDs to exclude those objects from\n    your search.\n\n    Example:\n\n        >>> find_ref_chain(obj, lambda x: isinstance(x, MyClass))\n        [obj, ..., <MyClass object at ...>]\n\n    Returns ``[obj]`` if such a chain could not be found.\n\n    .. versionadded:: 1.7\n    '
    return _find_chain(obj, predicate, gc.get_referents, max_depth=max_depth, extra_ignore=extra_ignore)[::(- 1)]

dataset/ETHPy150Open Exa-Networks/exabgp/lib/exabgp/dep/objgraph.py find_ref_chain/original