'Find tests for the given object and any contained objects, and
add them to `tests`.'

def _find(self, tests, obj, name, module, source_lines, globs, seen):

    if self._verbose:
        print ('Finding    tests    in    %s' % name)
    if (id(obj) in seen):
        return
    seen[id(obj)] = 1
    test = self._get_test(obj, name, module, globs, source_lines)
    if (test is not None):
        tests.append(test)
    if (inspect.ismodule(obj) and self._recurse):
        for (valname, val) in obj.__dict__.items():
            if self._filter(val, name, valname):
                continue
            valname = ('%s.%s' % (name, valname))
            if ((inspect.isfunction(val) or inspect.isclass(val)) and self._from_module(module, val)):
                self._find(tests, val, valname, module, source_lines, globs, seen)
    if (inspect.ismodule(obj) and self._recurse):
        for (valname, val) in getattr(obj, '__test__', {}).items():
            if (not isinstance(valname, basestring)):
                raise ValueError(('DocTestFinder.find:    __test__    keys    must    be    strings:    %r' % (type(valname),)))
            if (not (inspect.isfunction(val) or inspect.isclass(val) or inspect.ismethod(val) or inspect.ismodule(val) or isinstance(val, basestring))):
                raise ValueError(('DocTestFinder.find:    __test__    values    must    be    strings,    functions,    methods,    classes,    or    modules:    %r' % (type(val),)))
            valname = ('%s.__test__.%s' % (name, valname))
            self._find(tests, val, valname, module, source_lines, globs, seen)
    if (inspect.isclass(obj) and self._recurse):
        for (valname, val) in obj.__dict__.items():
            if self._filter(val, name, valname):
                continue
            if isinstance(val, staticmethod):
                val = getattr(obj, valname)
            if isinstance(val, classmethod):
                val = getattr(obj, valname).im_func
            if ((inspect.isfunction(val) or inspect.isclass(val) or isinstance(val, property)) and self._from_module(module, val)):
                valname = ('%s.%s' % (name, valname))
                self._find(tests, val, valname, module, source_lines, globs, seen)
