<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def do_json_dupes_for_keys(self, params):
 """ \x1b[1mNAME\x1b[0m json_duples_for_keys - Gets the duplicate znodes for the given keys \x1b[1mSYNOPSIS\x1b[0m json_dupes_for_keys <path> <keys> [prefix] [report_errors] [first] \x1b[1mDESCRIPTION\x1b[0m Znodes with duplicated keys are sorted and all but the first (original) one are printed. \x1b[1mOPTIONS\x1b[0m * prefix: only include matching znodes * report_errors: turn on error reporting (i.e.: bad JSON in a znode) * first: print the first, non duplicated, znode too. \x1b[1mEXAMPLES\x1b[0m > json_cat /configs/primary_service true member_0000000186 { "status": "ALIVE", "serviceEndpoint": { "http": { "host": "10.0.0.2", "port": 31994 } }, "shard": 0 } member_0000000187 { "status": "ALIVE", "serviceEndpoint": { "http": { "host": "10.0.0.2", "port": 31994 } }, "shard": 0 } > json_dupes_for_keys /configs/primary_service shard member_0000000187 """

        try:
            Keys.validate(params.keys)
        except Keys.Bad as ex:
            self.show_output(str(ex))
            return

        path_map = PathMap(self._zk, params.path)

        dupes_by_path = defaultdict(lambda: defaultdict(list))
        for path, data in path_map.get():
            parent, child = split(path)

            if not child.startswith(params.prefix):
                continue

            try:
                value = Keys.value(json_deserialize(data), params.keys)
                dupes_by_path[parent][value].append(path)
            except BadJSON as ex:
                if params.report_errors:
                    self.show_output("Path %s has bad JSON.", path)
            except Keys.Missing as ex:
                if params.report_errors:
                    self.show_output("Path %s is missing key %s.", path, ex)

        dupes = []
        for _, paths_by_value in dupes_by_path.items():
            for _, paths in paths_by_value.items():
                if len(paths) > 1:
                    paths.sort()
                    paths = paths if params.first else paths[1:]
                    for path in paths:
                        idx = bisect.bisect(dupes, path)
                        dupes.insert(idx, path)

        for dup in dupes:
            self.show_output(dup)

        # if no dupes were found we call it a failure (i.e.: exit(1) from --run-once)
        if len(dupes) == 0:
            return False