On the trace of an endofunctor of a small category