def simulate_until_attractor_or_max_t_storing_all_states(max_attractor_l,
    _simulate_until_attractor_or_target_substate_or_max_t, initial_state,
    perturbed_nodes_by_t, predecessor_node_lists, truth_tables):
    """
    Simulates until attractor is found (or one of optionally given constrains is exceeded).

    State is not considered as part of the attractor until all the perturbations are carried out. Initial state
    can be considered as part of the attractor only if no perturbations are present.

    :param max_attractor_l: maximum length of attractor to search for
    :param _simulate_until_attractor_or_target_substate_or_max_t: [function]
    to perform simulation accounting for the time cap (if any)
    :param initial_state: initial state of the network
    :param perturbed_nodes_by_t: dict (by time step) of dicts (by node) of
        node states
    :param predecessor_node_lists: list of predecessor node lists
    :param truth_tables: list of dicts (key: tuple of predecessor node states,
        value: resulting node state)
    :return attractor or None if not found
    """
    attractor = None
    (states, state_codes_since_last_perturbation, _, attractor_is_found, *_
        ) = (_simulate_until_attractor_or_target_substate_or_max_t(
        initial_state, perturbed_nodes_by_t, predecessor_node_lists,
        truth_tables))
    if attractor_is_found:
        attractor_first_state_code = state_codes_since_last_perturbation[-1]
        attractor_trajectory_l = state_codes_since_last_perturbation.index(
            attractor_first_state_code)
        attractor_l = len(state_codes_since_last_perturbation) - (
            attractor_trajectory_l + 1)
        if attractor_l <= max_attractor_l:
            attractor_state_codes = state_codes_since_last_perturbation[-
                attractor_l:]
            attractor_min_state_code = min(attractor_state_codes)
            attractor_states = states[-attractor_l:]
            attractor_trajectory_l = len(states) - (attractor_l + 1)
            attractor = (attractor_min_state_code, attractor_state_codes,
                attractor_states, attractor_trajectory_l)
    return attractor
