Helper to construct the list of nodes and edges.

def _independent_lattice(self, shape, lattice=None):
        """ Helper to construct the list of nodes and edges. """
        I, J = shape

        if lattice is not None:
            end_I = min(I, max(lattice[..., 3])) - 1
            end_J = min(J, max(lattice[..., 4])) - 1
            unvisited_nodes = deque([(i, j, s)
                                     for i in range(end_I)
                                     for j in range(end_J)
                                     for s in self._start_states])
            lattice = lattice.tolist()
        else:
            lattice = []
            unvisited_nodes = deque([(0, 0, s) for s in self._start_states])
        lattice += _grow_independent_lattice(self._transitions, 
                                             self.n_states, (I, J), 
                                             unvisited_nodes)
        lattice = np.array(sorted(lattice), dtype='int64')
        return lattice