def nearest_material_roughness(name, clean=None):
    r'''Searches through either a dict of clean pipe materials or used pipe
    materials and conditions and returns the ID of the nearest material.
    Search is performed with either the standard library's difflib or with
    the fuzzywuzzy module if available.

    Parameters
    ----------
    name : str
        Search term for matching pipe materials
    clean : bool, optional
        If True, search only clean pipe database; if False, search only the
        dirty database; if None, search both

    Returns
    -------
    ID : str
        String for lookup of roughness of a pipe, in either 
        `roughness_clean_dict` or `HHR_roughness` depending on if clean is 
        True, [-]
        
    Examples
    --------
    >>> nearest_material_roughness('condensate pipes', clean=False)
    'Seamless steel tubes, Condensate pipes in open systems or periodically operated steam pipelines'

    References
    ----------
    .. [1] Idelʹchik, I. E, and A. S Ginevskiĭ. Handbook of Hydraulic 
       Resistance. Redding, CT: Begell House, 2007.
    '''
    d = _all_roughness if clean is None else (roughness_clean_dict if clean else HHR_roughness)
    return fuzzy_match(name, d.keys())
r'''Searches through either a dict of clean pipe materials or used pipe
    materials and conditions and returns the ID of the nearest material.
    Search is performed with either the standard library's difflib or with
    the fuzzywuzzy module if available.

    Parameters
    ----------
    name : str
        Search term for matching pipe materials
    clean : bool, optional
        If True, search only clean pipe database; if False, search only the
        dirty database; if None, search both

    Returns
    -------
    ID : str
        String for lookup of roughness of a pipe, in either 
        `roughness_clean_dict` or `HHR_roughness` depending on if clean is 
        True, [-]
        
    Examples
    --------
    >>> nearest_material_roughness('condensate pipes', clean=False)
    'Seamless steel tubes, Condensate pipes in open systems or periodically operated steam pipelines'

    References
    ----------
    .. [1] Idelʹchik, I. E, and A. S Ginevskiĭ. Handbook of Hydraulic 
       Resistance. Redding, CT: Begell House, 2007.