def load_config_merged(conf_files, template=None, template_env=None, as_dict=False, root=None):
    confs = []
    for f in conf_files:
        if root is not None:
            f = os.path.join(root, f)
        if os.path.exists(f):
            INFO("loading config from file %s" % f)

            f = open(f, 'r')
            config = yaml_utils.load(f, template=template, template_env=template_env)
            f.close()
            confs.append(config)

    if confs:
        config = confs[0]
        for i in range(1, len(confs)):
            config.update(confs[i])

        if not as_dict:
            config = configure.Configuration.from_dict(config)

        return config
    return None
    if isinstance(c, configure.Configuration):
        r = {}
        for k in c:
            r[k] = config_to_dict(c[k])
        return r
    else:
        return c

def load_pkg_resource_config(pkg, resource, as_dict=True, **kwargs):
    import pkg_resources
    try:
        f = pkg_resources.resource_stream(pkg, resource)
    except IOError, e:
        return None

    config = yaml_utils.load(f, **kwargs)
    f.close()
    if not as_dict:
        cc = configure.Configuration
        config = cc.from_dict(config)
    return config

def load_config_from_package(pkg, filename):
    return load_pkg_resource_config(pkg, filename)

def load_config_from_packages(pkgs, filename):
    c = {}
    for p in pkgs:
        d = load_config_from_package(p, filename)
        if not d:
            continue