def only_on_root(func, *args, **kwargs):
    """
    This function accepts a *func*, a set of *args* and *kwargs* and then only
    on the root processor calls the function.  All other processors get "None"
    handed back.
    """
    from yt.config import ytcfg
    if kwargs.pop('global_rootonly', False):
        cfg_option = '__global_parallel_rank'
    else:
        cfg_option = '__topcomm_parallel_rank'
    if not ytcfg.getboolean('yt', '__parallel'):
        return func(*args, **kwargs)
    if ytcfg.getint('yt', cfg_option) > 0:
        return
    return func(*args, **kwargs)
