def replace_word(word_array, dict_of_words_to_replace):
    """
    Given an array of words, replace any words matching a key in dict_of_words_to_replace with its corresponding
    value.
    :param word_array: The array of words to check.
    :param dict_of_words_to_replace: The dictionary of words to replace paired with their replacements.
    :return: The new array of words.
    """
    new_word_array = []
    for word in word_array:
        if word in dict_of_words_to_replace:
            new_word_array.extend(dict_of_words_to_replace[word])
        else:
            new_word_array.append(word)
    return new_word_array