def serialize(
        self: "Model", children: List["Model"], handler: SerializerFunctionWrapHandler
    ) -> Any:
        """
        Serialize a list of nodes, handling circular references
        by excluding the children.
        """
        try:
            with warnings.catch_warnings():
                warnings.filterwarnings(
                    "ignore", message="Pydantic serializer warnings"
                )
                return handler(children)
        except ValueError as exc:  # pragma: no cover
            if not str(exc).startswith("Circular reference"):
                raise exc

            result = []
            for child in children:
                # If there is one circular ref dump all children as pk only
                result.append({child.ormar_config.pkname: child.pk})
            return result

        Serialize a list of nodes, handling circular references
        by excluding the children.
        
ormar/models/helpers/relations.py