def _events_under_record_root(self, events: pd.DataFrame) -> pd.DataFrame:
        """
        Get events that are under the record root.

        Args:
            events: A pandas DataFrame of events.

        Returns:
            The events that are under the record root.
        """
        # Construct a tree of events.
        record_roots = []
        span_id_to_children = {
            event["trace"]["span_id"]: [] for _, event in events.iterrows()
        }
        for i, event in events.iterrows():
            parent_id = event["trace"]["parent_id"]
            if parent_id and parent_id in span_id_to_children:
                span_id_to_children[parent_id].append(event)
            if (
                event["record_attributes"].get(SpanAttributes.SPAN_TYPE)
                == SpanAttributes.SpanType.RECORD_ROOT
            ):
                record_roots.append(event)
        # Get events under the record root.
        if len(record_roots) != 1:
            return pd.DataFrame()
        ret = []
        q = [record_roots[0]]
        while q:
            curr_event = q.pop(0)
            ret.append(curr_event)
            q.extend([
                child_event
                for child_event in span_id_to_children[
                    curr_event["trace"]["span_id"]
                ]
            ])
        return pd.DataFrame(ret)

        Get events that are under the record root.

        Args:
            events: A pandas DataFrame of events.

        Returns:
            The events that are under the record root.
        
src/core/trulens/core/utils/evaluator.py