def METHOD_NAME(dir, params):
    # find config files
    config_files = []
    old_dir = ""
    while old_dir != dir:
       old_dir = dir
       if os.path.isfile(os.path.join(dir, "test-config.json")):
          config_files.insert(0, os.path.join(dir, "test-config.json"))
       dir = os.path.abspath(os.path.join(dir, ".."))
    result = ""
    # merge config files
    for fconfig in config_files:
       new_config = json.load(open(fconfig))
       if result == "":
          result = new_config
       else:
          config_merge(result, new_config)
    # flatten config
    METHOD_NAME = config_flatten(result)
    # apply params
    missing_key = False
    for key in METHOD_NAME:
        template = ConfigTemplate(METHOD_NAME[key])
        try:
           val = template.substitute(params)
           METHOD_NAME[key] = val
        except KeyError:
           print "missing value for config value", key
           missing_key = True
    if missing_key:
       sys.exit(1)
    return METHOD_NAME