def _iterate_parents()

in mozci/push.py [0:0]


    def _iterate_parents(self, max_depth=None):
        other = self
        for i in itertools.count():
            yield other

            # Optimization to load parent json-pushes data in a single query (up
            # to max_depth at a time).
            prev_id = other.id - 1
            if prev_id not in HgRev.JSON_PUSHES_CACHE:
                depth = max_depth or MAX_DEPTH
                HgRev.load_json_pushes_between_ids(
                    self.branch, max(prev_id - 1 - depth + i, 0), prev_id
                )

            try:
                other = other.parent
            except ParentPushNotFound:
                break

            if max_depth is not None and i == max_depth:
                break