def METHOD_NAME(mesh, root=None):
    """Unify the cycle directions of all faces.
    Unified cycle directions is a necessary condition for the data structure to
    work properly. When in doubt, run this function on your mesh.
    Parameters
    ----------
    mesh : :class:`~compas.datastructures.Mesh`
        A mesh object.
    root : str, optional
        The key of the root face.
    Returns
    -------
    None
        The mesh is modified in place.
    Raises
    ------
    AssertionError
        If no all faces are included in the unnification process.
    """
    def unify(node, nbr):
        # find the common edge
        for u, v in mesh.face_halfedges(nbr):
            if u in mesh.face[node] and v in mesh.face[node]:
                # node and nbr have edge u-v in common
                i = mesh.face[node].index(u)
                j = mesh.face[node].index(v)
                if i == j - 1 or (j == 0 and u == mesh.face[node][-1]):
                    # if the traversal of a neighboring halfedge
                    # is in the same direction
                    # flip the neighbor
                    mesh.face[nbr][:] = mesh.face[nbr][::-1]
                    return
    if root is None:
        root = mesh.face_sample(size=1)[0]
    adj = mesh_face_adjacency(mesh)
    visited = breadth_first_traverse(adj, root, unify)
    assert len(list(visited)) == mesh.number_of_faces(), "Not all faces were visited"
    mesh.halfedge = {key: {} for key in mesh.vertices()}
    for fkey in mesh.faces():
        for u, v in mesh.face_halfedges(fkey):
            mesh.halfedge[u][v] = fkey
            if u not in mesh.halfedge[v]:
                mesh.halfedge[v][u] = None