def _chimera_neighbors(M, N, L, q):
    "Returns a list of neighbors of (x,y,u,k) in a perfect :math:`C_{M,N,L}`"
    (x, y, u, k) = q
    n = [(x, y, 1 - u, l) for l in range(L)]
    if u == 0:
        if x:
            n.append((x - 1, y, u, k))
        if x < M - 1:
            n.append((x + 1, y, u, k))
    else:
        if y:
            n.append((x, y - 1, u, k))
        if y < N - 1:
            n.append((x, y + 1, u, k))
    return n
Returns a list of neighbors of (x,y,u,k) in a perfect :math:`C_{M,N,L}`