<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def loadBWT(bwtDir, logger=None):
    '''
    Generic load function, this is recommended for anyone wishing to use this code as it will automatically detect compression
    and assign the appropriate class preferring the decompressed version if both exist.
    @return - a MultiStringBWT, CompressedBWT, or none if neither can be instantiated
    '''
    if os.path.exists(bwtDir+'/msbwt.npy'):
        msbwt = MultiStringBWT()
        msbwt.loadMsbwt(bwtDir, logger)
        return msbwt
    elif os.path.exists(bwtDir+'/comp_msbwt.npy'):
        msbwt = CompressedMSBWT()
        msbwt.loadMsbwt(bwtDir, logger)
        return msbwt
    else:
        logger.error('Invalid BWT directory.')
        return None