//  [python]
def __init__(self, baseref: Reference, edge_refs: Tuple[Reference,...], midpoint: types.arraydata):
        assert isinstance(baseref, Reference), f'baseref={baseref!r}'
        assert isinstance(edge_refs, tuple) and len(edge_refs) == baseref.nedges and all(isinstance(ref, Reference) and ref.ndims == baseref.ndims-1 for ref in edge_refs), f'baseref={baseref!r}'
        assert edge_refs != tuple(baseref.edge_refs)
        assert midpoint.shape == (baseref.ndims,)
        assert all(n.all(edge.vertices == newedge.vertices[:edge.nverts])
            for edge, newedge in zip(baseref.edge_refs, edge_refs))

        vertices = list(baseref.vertices)
        match, = (baseref.vertices == midpoint).all(1).nonzero()
        if match.size:
            imidpoint, = match
        else:
            imidpoint = len(vertices)
            vertices.append(numpy.asarray(midpoint))

        # The remainder of this constructor is concerned with establishing the
        # edges of the mosaic, and setting up the corresponding edge-vertex
        # relations.

        if baseref.ndims == 1:

            # For 1D elements the situation is simple: the midpoint represents
            # the only new vertex (already added to vertices) as well as the
            # only new edge, with a trivial edge-vertex relationship.

            assert not match.size, '1D mosaic must introduce a new vertex'
            edge_vertices = (*baseref.edge_vertices, types.frozenarray([imidpoint]))
            orientation = [not trans.isflipped for trans, edge in zip(baseref.edge_transforms, edge_refs) if edge]
            assert len(orientation) == 1, 'invalid 1D mosaic: exactly one edge should be non-empty'

        else:

            # For higher-dimensional elements the situation is more complex.
            # Firstly, the new edge_refs may introduce new vertices. Luckily
            # here the previously asserted convention applies that the vertices
            # of the original edge are repeated in the modified edge, so we can
            # focus our attention on the new ones, having only to deduplicate
            # between them.

            edge_vertices = []
            for trans, edge, emap, newedge in zip(baseref.edge_transforms, baseref.edge_refs, baseref.edge_vertices, edge_refs):
                for v in trans.apply(newedge.vertices[edge.nverts:]):
                    for i, v_ in enumerate(vertices[baseref.nverts:], start=baseref.nverts):
                        if (v == v_).all():
                            break # the new vertex was already added by a previous edge
                    else:
                        i = len(vertices)
                        vertices.append(v)
                    emap = types.frozenarray([*emap, i])
                edge_vertices.append(emap)

            # Secondly, new edges (which will be pulled to the midpoint) can
            # originate either from new edge-edges, or from existing ones that
            # find themselves without a counterpart. The former situation is
            # trivial, following the convention that existing edge transforms
            # are copied over in the modified edge.

            assert all(edge.edge_transforms == newedge.edge_transforms[:edge.nverts]
                for edge, newedge in zip(baseref.edge_refs, edge_refs))

            # The latter, however, is more tricky. This is the situation that
            # occurs, for instance, when two out of four edges of a square are
            # cleanly removed, making two existing edge-edges the new exterior.
            # Identifying these situations requires an examination of all the
            # modified edges, that is, edge-edges in locations that pre-existed
            # in baseref. Knowing that the edges of baseref form a watertight
            # hull, we employ the strategy of first identifying all edge-edge
            # counterparts, and then comparing the new references in the
            # identified locations to see if one of the two disappeared: in
            # this case the other reference is added to the exterior set.

            # NOTE: establishing edge-edge relations could potentially be
            # cached for reuse at the level of baseref. However, since this is
            # the only place that the information is used and all edge pairs
            # need to anyhow be examined for gaps, it is not clear that the
            # gains merit the additional complexity.

            orientation = []
            seen = {}
            for edge1, newemap1, etrans1, newedge1 in zip(baseref.edge_refs, edge_vertices, baseref.edge_transforms, edge_refs):
                newedge1_edge = zip(newedge1.edge_vertices, newedge1.edge_transforms, newedge1.edge_refs)
                trimmed = [] # trimmed will be populated with a subset of newedge1_edge
                for edge2, (newemap2, etrans2, newedge2) in zip(edge1.edge_refs, newedge1_edge):
                    if edge2: # existing non-empty edge

                        # To identify matching edge-edges we map their vertices
                        # to the numbering of the baseref for comparison. Since
                        # matching edge-edges have must have equal references,
                        # and by construction have matching orientation, the
                        # vertex ordering will be consistent between them.

                        key = tuple(newemap1[newemap2])

                        # NOTE: there have been anecdotal reports that suggest
                        # the assumption of matching edges may be violated, but
                        # it is not clear in what scenario this can occur. If
                        # the 'not seen' assertion below fails, please provide
                        # the developers with a reproducable issue for study.

                        try:
                            newedge2_ = seen.pop(key)
                        except KeyError:
                            seen[key] = newedge2
                        else: # a counterpart is found, placing newedge2 against newedge2_
                            if not newedge2:
                                trimmed.append((newemap2, etrans2.flipped, newedge2_))
                            elif not newedge2_:
                                trimmed.append((newemap2, etrans2, newedge2))
                            elif newedge2 != newedge2_:
                                raise NotImplementedError

                # Since newedge1_edge was zipped against the shorter list of
                # original edge1.edge_refs, what remains are the new edge-edges
                # that can be added without further examination.

                trimmed.extend(newedge1_edge)

                # What remains is only to extend the edge-vertex relations and
                # to track if the new edges are left- or right-handed.

                for newemap2, etrans2, newedge2 in trimmed:
                    for simplex in newemap1[newemap2[newedge2.simplices]]:
                        if imidpoint not in simplex:
                            edge_vertices.append(types.frozenarray([imidpoint, *simplex]))
                            orientation.append(not etrans1.isflipped^etrans2.isflipped)

            assert not seen, f'leftover unmatched edges ({seen}) indicate the edges of baseref ({baseref}) are not watertight!'

        self.baseref = baseref
        self._edge_refs = edge_refs
        self.vertices = types.frozenarray(vertices, copy=False)
        self._imidpoint = imidpoint
        self._midpoint = midpoint
        self.edge_vertices = tuple(edge_vertices)
        self.edge_refs = edge_refs + (getsimplex(baseref.ndims-1),) * len(orientation)
        self.edge_transforms = baseref.edge_transforms + tuple(transform.simplex(vertices, isflipped)
          for vertices, isflipped in zip(self.vertices[numpy.array(edge_vertices[baseref.nedges:])], orientation))

        super().__init__(baseref.ndims)