'Return single movie that best matches name criteria or None'

def best_match(self, name, year=None, single_match=True):

    movies = self.search(name)
    if (not movies):
        log.debug(u'search    did    not    return    any    movies')
        return None
    for movie in movies[:]:
        if (year and movie.get(u'year')):
            if (movie[u'year'] != str(year)):
                log.debug((u'best_match    removing    %s    -    %s    (wrong    year:    %s)' % (movie[u'name'], movie[u'url'], str(movie[u'year']))))
                movies.remove(movie)
                continue
        if (movie[u'match'] < self.min_match):
            log.debug(u'best_match    removing    %s    (min_match)', movie[u'name'])
            movies.remove(movie)
            continue
    if (not movies):
        log.debug(u'FAILURE:    no    movies    remain')
        return None
    if (len(movies) == 1):
        log.debug(u'SUCCESS:    only    one    movie    remains')
        return movies[0]
    diff = (movies[0][u'match'] - movies[1][u'match'])
    if (diff < self.min_diff):
        log.debug((u'unable    to    determine    correct    movie,    min_diff    too    small    (`%s`    <-?->    `%s`)' % (movies[0], movies[1])))
        for m in movies:
            log.debug((u'remain:    %s    (match:    %s)    %s' % (m[u'name'], m[u'match'], m[u'url'])))
        return None
    else:
        return (movies[0] if single_match else movies)
