def extract_tagged_plane(self, obj: bpy.types.Object, tags: set, plane: int):
        """
        get a single plane formed by faces tagged with tags
        """

        if obj.type != "MESH":
            raise TypeError("Object is not a mesh!")

        face_mask = tagging.tagged_face_mask(obj, tags)
        mask = self.tagged_plane_mask(obj, face_mask, plane)

        if not mask.any():
            obj_tags = tagging.union_object_tags(obj)
            logger.warning(
                f"Attempted to extract_tagged_plane {obj.name=} {tags=} but mask was empty, {obj_tags=}"
            )

        butil.select(obj)
        bpy.context.view_layer.objects.active = obj

        bpy.ops.object.mode_set(mode="EDIT")
        bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type="FACE")
        bpy.ops.mesh.select_all(action="DESELECT")
        # Set initial selection for polygons to False
        bpy.ops.object.mode_set(mode="OBJECT")

        for poly in obj.data.polygons:
            poly.select = mask[poly.index]

        # Switch to Edit mode, duplicate the selection, and separate it
        old_set = set(bpy.data.objects[:])
        bpy.ops.object.mode_set(mode="EDIT")
        bpy.ops.mesh.duplicate()
        bpy.ops.mesh.separate(type="SELECTED")
        bpy.ops.object.mode_set(mode="OBJECT")
        new_set = set(bpy.data.objects[:]) - old_set
        return new_set.pop()

        get a single plane formed by faces tagged with tags
        
infinigen/core/constraints/example_solver/geometry/planes.py