def is_imported_module(in_module, m, qualified_name = None):
    """
    Returns whether 'm' is imported from 'in_module'
    If 'qualified_name' specified, 'm' must be 'qualified_name' or imported as 'qualified_name'
    """
    if qualified_name:
        if m.name in in_module.imports:
            cur_import = in_module.imports[m.name]
            return cur_import.module == qualified_name or cur_import.import_as == qualified_name
        return False
    else:
        if m.name in in_module.imports:
            return (not in_module.imports[m.name].is_qualified)
        # Return True also on Prelude
        return m.name == 'Prelude'