'Find titles or names references in strings.'

def _findRefs(self, o, trefs, nrefs):

    if isinstance(o, (unicode, str)):
        for title in re_titleRef.findall(o):
            a_title = analyze_title(title, canonical=0)
            rtitle = build_title(a_title, ptdf=1)
            if trefs.has_key(rtitle):
                continue
            movieID = self._getTitleID(rtitle)
            if (movieID is None):
                movieID = self._getTitleID(title)
            if (movieID is None):
                continue
            m = Movie(title=rtitle, movieID=movieID, accessSystem=self.accessSystem)
            trefs[rtitle] = m
            rtitle2 = canonicalTitle(a_title.get('title', u''))
            if (rtitle2 and (rtitle2 != rtitle) and (rtitle2 != title)):
                trefs[rtitle2] = m
            if (title != rtitle):
                trefs[title] = m
        for name in re_nameRef.findall(o):
            a_name = analyze_name(name, canonical=1)
            rname = build_name(a_name, canonical=1)
            if nrefs.has_key(rname):
                continue
            personID = self._getNameID(rname)
            if (personID is None):
                personID = self._getNameID(name)
            if (personID is None):
                continue
            p = Person(name=rname, personID=personID, accessSystem=self.accessSystem)
            nrefs[rname] = p
            rname2 = normalizeName(a_name.get('name', u''))
            if (rname2 and (rname2 != rname)):
                nrefs[rname2] = p
            if ((name != rname) and (name != rname2)):
                nrefs[name] = p
    elif isinstance(o, (list, tuple)):
        for item in o:
            self._findRefs(item, trefs, nrefs)
    elif isinstance(o, dict):
        for value in o.values():
            self._findRefs(value, trefs, nrefs)
    return (trefs, nrefs)
