def merge_markers(result: Result[Requirement, Candidate, str]) -> dict[str, Marker]:
    """Traverse through the parent dependencies till the top
    and merge any requirement markers on the path.
    Return a map of Metaset for each candidate.
    """
    all_markers: dict[str, Marker] = {}
    unresolved = OrderedSet(result.mapping)
    circular: dict[str, OrderedSet[str]] = {}

    while unresolved:
        new_markers: dict[str, Marker] = {}
        for k in unresolved:
            crit = result.criteria[k]
            keep_unresolved = circular.get(k) or OrderedSet()
            # All parents must be resolved first
            if any(p and _identify_parent(p) in (unresolved - keep_unresolved) for p in crit.iter_parent()):
                continue
            new_markers[k] = _build_marker(crit, all_markers, keep_unresolved)

        if new_markers:
            all_markers.update(new_markers)
            unresolved -= new_markers  # type: ignore[assignment,operator]
        else:
            # No progress, there are likely circular dependencies.
            # Pick one package and keep its parents unresolved now, we will get into it
            # after all others are resolved.
            package = next((p for p in unresolved if p not in circular), None)
            if not package:
                break
            crit = result.criteria[package]
            unresolved_parents = OrderedSet(
                filter(
                    lambda p: p in unresolved and p != package,
                    (_identify_parent(p) for p in crit.iter_parent() if p),
                )
            )
            circular[package] = unresolved_parents

    for key in circular:
        crit = result.criteria[key]
        all_markers[key] = _build_marker(crit, all_markers, set())

    return all_markers
Traverse through the parent dependencies till the top
    and merge any requirement markers on the path.
    Return a map of Metaset for each candidate.
    
src/pdm/resolver/graph.py