def causal_nexus(network, before_state, after_state,
                 direction=Direction.BIDIRECTIONAL):
    """Return the causal nexus of the network."""
    validate.is_network(network)

    log.info("Calculating causal nexus...")
    result = nexus(network, before_state, after_state, direction)
    if result:
        result = max(result)
    else:
        null_transition = Transition(
            network, before_state, after_state, (), ())
        result = _null_ac_sia(null_transition, direction)

    log.info("Finished calculating causal nexus.")
    log.debug("RESULT: \n%s", result)
    return result
Return the causal nexus of the network.