def is_datetime_inf_or_equal(date_ref, date_comp):
    """
        Compare if date_ref <= date_comp

        Compare efficiently if date_ref <= date_comp. The date_comp is duplicated to allow the
        chaining function: is datetime_inf_or_equal(a, b), datetime_inf_or_equal(b, c) ...

        :param date_ref: Reference date, format: [Year, Month, Day, Hour, Minute, Second]
        :param date_comp: Compare date, format: [Year, Month, Day, Hour, Minute, Second]
        :return: True if date_ref <= date_comp, False if date_ref > date_comp
    """
    i = 0
    while date_ref[i] == date_comp[i] and i != 4:
        i += 1
    if date_ref[i] < date_comp[i] or i == 4:
        return True
    return False
