def fix_imports(self, token):
        if token.type == 'keyword' and token.text == 'import': 
            tokens = token.line_tokens
            
            # For each import case ...
            for name, replacement in self.IMPORT_MAPPING.items():
                parts = name.split('.')
                # Walk over tokens to find start of match
                for i in range(len(tokens)):
                    if (tokens[i].text == parts[0] and
                            len(tokens[i:]) >= len(parts)):
                        # Is it a complete match?
                        for j, part in enumerate(parts):
                            if tokens[i+j].text != part:
                                break
                        else:
                            # Match, marge tokens
                            tokens[i].end = tokens[i+len(parts)-1].end
                            tokens[i].fix = replacement
                            for j in range(1, len(parts)):
                                tokens[i+j].start = tokens[i].end
                                tokens[i+j].end = tokens[i].end
                                tokens[i+j].fix = ''
                            break  # we have found the match
import xx.yy -> import zz
dataset/ETHPy150Open zoofIO/flexx/translate_to_legacy.py/LegacyPythonTranslator.fix_imports