<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_best_match(self, options, service_name, api_version=None):
 """ Given a collection of possible service options, selects the best match. If no API version is provided, the path to the most recent API version will be returned. If an API version is provided & there is an exact match, the path to that version will be returned. If there is no exact match, an attempt will be made to find a compatible (earlier) version. In all cases, user-created files (if present) will be given preference over the default included versions. :param options: A dictionary of options. See :type options: dict :param service_name: The name of the desired service :type service_name: string :param api_version: (Optional) The desired API version to load :type service_name: string :returns: The full path to the best matching JSON file """

        if not options:
            msg = "No JSON files provided. Please check your " + \
                  "configuration/install."
            raise NoResourceJSONFound(msg)

        if api_version is None:
            # Give them the very latest option.
            best_version = max(options.keys())
            return options[best_version][0], best_version

        # They've provided an api_version. Try to give them exactly what they
        # requested, falling back to the best compatible match if no exact
        # match can be found.
        if api_version in options:
            return options[api_version][0], api_version

        # Find the best compatible match. Run through in descending order.
        # When we find a version that's lexographically less than the provided
        # one, run with it.
        for key in sorted(options.keys(), reverse=True):
            if key <= api_version:
                return options[key][0], key

        raise NoResourceJSONFound(
            "No compatible JSON could be loaded for {0} ({1}).".format(
                service_name,
                api_version
            )
        )