def get_package_name_and_type(package, known_extensions):
    """Return package name and type.

    Package type must exists in known_extensions list. Otherwise None is
    returned.

    >>> extensions = ['tar.gz', 'zip']
    >>> get_package_name_and_type('underscored_name.zip', extensions)
    ('underscored_name', 'zip')
    >>> get_package_name_and_type('unknown.extension.txt', extensions)
    """
    for package_type in known_extensions:
        if package.endswith('.'+package_type):
            # Package name is name of package without file extension
            # (ex. twill-7.3).
            return package[:package.rfind('.'+package_type)], package_type