def yaml_file_to_dict(script_name, path=None):
    def load_yaml(file_path):
        with open(file_path, 'r') as yamlfile:
            try:
                dictionary = yaml.load(yamlfile)
            except yaml.YAMLError:
                return {}
        return dictionary
    def merge(user, default):
        if isinstance(user, dict) and isinstance(default, dict):
            for k, v in default.iteritems():
                if k not in user:
                    user[k] = v
                else:
                    user[k] = merge(user[k], v)
        return user
    if path is None:
        path = os.path.abspath('.')
    config_file_path = os.path.join(path, script_name + '.yaml')
    if not os.path.exists(config_file_path):
        raise RuntimeError('Config file does not exist: {}'.format(config_file_path))
    default_dict = load_yaml(config_file_path)
    user_config_file_path = os.path.join(os.path.expanduser('~'), '.condoor', os.path.basename(script_name) + '.yaml')
    user_config_file_path = os.getenv('CONDOOR_' + os.path.basename(script_name).upper(), user_config_file_path)
    if os.path.exists(user_config_file_path):
        user_dict = load_yaml(user_config_file_path)
        if user_dict:
            default_dict = merge(user_dict, default_dict)
    return default_dict