code: def getrruleset(self, addRDate=False):
          rruleset = None
          for name in DATESANDRULES:
              addfunc = None
              for line in self.contents.get(name, ()):
                  if rruleset is None:
                      rruleset = rrule.rruleset()
                  if addfunc is None:
                      addfunc = getattr(rruleset, name)
                  if name in DATENAMES:
                      if type(line.value[0]) == datetime.datetime:
                          map(addfunc, line.value)
                      elif type(line.value[0]) == datetime.date:
                          for dt in line.value:
                              addfunc(datetime.datetime(dt.year, dt.month, dt.day))
                      else:
                          pass
                  elif name in RULENAMES:
                      try:
                          dtstart = self.dtstart.value
                      except (AttributeError, KeyError):
                          try:
                              if self.name == "VTODO":
                                  dtstart = self.due.value
                              else:
                                  print('failed to get dtstart with VTODO')
                                  return None
                          except (AttributeError, KeyError):
                              print('failed to find DUE at all.')
                              return None
                      value = str_(line.value).replace('\\', '')
                      rule = rrule.rrulestr(value, dtstart=dtstart)
                      until = rule._until
                      if until is not None and isinstance(dtstart, datetime.datetime) and \
                         (until.tzinfo != dtstart.tzinfo):
                          vals = dict(pair.split('=') for pair in
                                      line.value.upper().split(';'))
                          if len(vals.get('UNTIL', '')) == 8:
                              until = datetime.datetime.combine(until.date(), dtstart.time())
                          if until.tzinfo is None:
                              until = until.replace(tzinfo=dtstart.tzinfo)
                          if dtstart.tzinfo is not None:
                              until = until.astimezone(dtstart.tzinfo)
                          if dtstart.tzinfo is None:
                              until = until.replace(tzinfo=None)
                          rule._until = until
                      addfunc(rule)
                      if name == 'rrule' and addRDate:
                          try:
                              if not isinstance(dtstart, datetime.datetime):
                                  adddtstart = datetime.datetime.fromordinal(dtstart.toordinal())
                              else:
                                  adddtstart = dtstart
                              if rruleset._rrule[-1][0] != adddtstart:
                                  rruleset.rdate(adddtstart)
                                  added = True
                              else:
                                  added = False
                          except IndexError:
                              added = False
                          if added and rruleset._rrule[-1]._count is not None:
                              rruleset._rrule[-1]._count -= 1
          return rruleset