def METHOD_NAME(self, word, distance):
    """Find the best match with {word} in a trie.
    :arg str word: Query word.
    :arg int distance: Maximum allowed distance.
    :returns str: Best match with {word}.
    """
    if self.get(word):
        return word
    for i in range(1, distance + 1):
        result = self.hamming(word, i)
        if result is not None:
            return result
    return None