You can use VersionControlServer.GetTeamProjectForServerPath on a pending change thus:
var pendingChange = pendingCheckin.GetAllPendingChanges().FirstOrDefault();
if(pendingChange != null) {
return vcs.GetTeamProjectForServerPath(pendingChange.ServerItem);
}
This also means you can detect if pending changes span multiple team projects.
Edit/expansion:
Now that I think about it, you should probably use the local path, since the files you're checking in might not be on the server yet (adds).
So you can use Workspace.GetTeamProjectForLocalPath instead:
var workspace = pendingCheckin.GetWorkspace();
var pendingChange = pendingCheckin.GetAllPendingChanges().FirstOrDefault();
if(pendingChange != null) {
return workspace.GetTeamProjectForLocalPath(pendingChange.LocalItem);
}