<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_files(self, common_name, delete_dir=False):
 """Delete files and record associated with this common name"""


        record = self.remove_record(common_name)
        if delete_dir:
            delete_dirs = []
            if 'files' in record:
                key_containing_dir = os.path.dirname(record['files']['key'])
                delete_dirs.append(key_containing_dir)
                cert_containing_dir = os.path.dirname(record['files']['cert'])
                if key_containing_dir != cert_containing_dir:
                    delete_dirs.append(cert_containing_dir)
                for d in delete_dirs:
                    shutil.rmtree(d)
        return record