def get_ip(record, direction):
    """
    Return required IPv4 or IPv6 address (source or destination) from given record.

    :param record: JSON record searched for IP
    :param direction: string from which IP will be searched (e.g. "source" => ipfix.sourceIPv4Address or
                      "destination" => ipfix.destinationIPv4Address)
    :return: value corresponding to the key in the record
    """
    key_name = "ipfix." + direction + "IPv4Address"
    if key_name in record.keys():
        return record[key_name]
    key_name = "ipfix." + direction + "IPv6Address"
    return record[key_name]