code: def read_record(self, offset):
          _log.debug("in read_record(%s)", offset)
          stack = []
          reclevel = None
          for gline in self.gedcom_lines(offset):
              _log.debug("    read_record, gline: %s", gline)
              level = gline.level
              if reclevel is None:
                  reclevel = level
              elif level <= reclevel:
                  break
              for rec in reversed(stack[level:]):
                  if rec:
                      if rec.value is not None:
                          rec.value = rec.value.decode(self._encoding,
                                                       self._errors)
                      rec.freeze()
              del stack[level + 1:]
              stack.extend([None] * (level + 1 - len(stack)))
              parent = stack[level - 1] if level > 0 else None
              rec = self._make_record(parent, gline)
              stack[level] = rec
          for rec in reversed(stack[reclevel:]):
              if rec:
                  if rec.value is not None:
                      rec.value = rec.value.decode(self._encoding, self._errors)
                  rec.freeze()
                  _log.debug("    read_record, rec: %s", rec)
          return stack[reclevel] if stack else None