Iterating over all tensor compositions, we then generate all possible diagrams representing traces of one-body operators. These diagrams are encoded as ordered lists I of the indices of each tensor. To calculate all diagrams of interest, we simply consider all possible sets of indices, where each index occurs exactly twice. The diagram corresponding to the trace of the BW-s2(α) regulariser would therefore be encoded as I = (i, j, a, b, i, j, a, b), where the first four indices belong to the ERI and the latter four indices belong to the amplitude. Given 2n indices, however, the naive approach of simply checking each permutation for every possible number of occupied and virtual orbitals scales as O(n • n!) and (especially combined with the computational effort of later steps) becomes prohibitively expensive very early. We therefore implement two further restrictions on the set of indices, which do not eliminate any valid diagram: First, there must be at least one occupied index. This is a necessary requirement for compliance with the constraints on computational scaling discussed previously. Second, we impose a special sorting requirement. Specifically, we demand that I be canonically sorted, otherwise it is rejected. To check canonical sorting, we build the sets of first occurrences I f occ and I f vir . Iterating over the elements of I in order, we add occupied indices to the end of I f occ if they are not already in I f occ . The same process applies for virtual indices into I f vir . I is canonically sorted if and only if both I f occ and I f vir are sorted. This restriction drastically cuts down on the number of redundant diagrams that can be generated from previously checked expressions by means of index permutations. While the scaling is only reduced to O(n • n!/(n/2)!), this amendment allows for feasible calculation of regulariser terms up to V ttt.