def count_signals(path: dict, signal="x"):
    """
    Count number of x's or y's in a path.
    :param path: Dictionary of linked nodes
    :param signal: 'x' or 'y'
    :return: Number of x's or y's in path
    """
    if signal not in ["x", "y"]:
        raise ValueError(f"Signal {signal} must be either 'x' or 'y'.")
    return len([di["signal"] for rank, di in path.items() if di["signal"] == signal])