Read next complete record from a file starting at given position.

        Reads the record at given position and all its sub-records. Stops
        reading at EOF or next record with the same or higher (smaller) level
        number. File position after return from this method is not specified,
        re-position file if you want to read other records.

        :param int offset: Position in file to start reading from.
        :return: :py:class:`model.Record` instance or None if offset points
            past EOF.
        :raises: :py:exc:`ParserError` if `offsets` does not point to the
            beginning of a record or for any parsing errors.

def read_record(self, offset):
        """Read next complete record from a file starting at given position.

        Reads the record at given position and all its sub-records. Stops
        reading at EOF or next record with the same or higher (smaller) level
        number. File position after return from this method is not specified,
        re-position file if you want to read other records.

        :param int offset: Position in file to start reading from.
        :return: :py:class:`model.Record` instance or None if offset points
            past EOF.
        :raises: :py:exc:`ParserError` if `offsets` does not point to the
            beginning of a record or for any parsing errors.
        """
        _log.debug("in read_record(%s)", offset)
        stack = []  # stores per-level current records
        reclevel = None
        for gline in self.gedcom_lines(offset):
            _log.debug("    read_record, gline: %s", gline)
            level = gline.level

            if reclevel is None:
                # this is the first record, remember its level
                reclevel = level
            elif level <= reclevel:
                # stop at the record of the same or higher (smaller) level
                break

            # All previously seen records at this level and below can
            # be finalized now
            for rec in reversed(stack[level:]):
                # decode bytes value into string
                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)
            del stack[level + 1:]

            # extend stack to fit this level (and make parent levels if needed)
            stack.extend([None] * (level + 1 - len(stack)))

            # make Record out of it (it can be updated later)
            parent = stack[level - 1] if level > 0 else None
            rec = self._make_record(parent, gline)

            # store as current record at this level
            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