def get_record_parent(self, record):
        """
        @raises NoParentError: on various error conditions
        """
        if record.mft_record_number() == 5:
            raise NoParentError("Root directory has no parent")

        fn = record.filename_information()
        if not fn:
            raise NoParentError("File has no filename attribute")

        parent_record_num = MREF(fn.mft_parent_reference())
        parent_seq_num = MSEQNO(fn.mft_parent_reference())

        try:
            parent_record = self._enumerator.get_record(parent_record_num)
        except (BinaryParser.OverrunBufferException, InvalidRecordException):
            raise NoParentError("Invalid parent MFT record")

        if parent_record.sequence_number() != parent_seq_num:
            raise NoParentError("Invalid parent MFT record (bad sequence number)")

        return NTFSDirectory(self, parent_record)
dataset/ETHPy150Open williballenthin/python-ntfs/ntfs/filesystem/__init__.py/NTFSFilesystem.get_record_parent/original