Thread:Project:Support desk/Can a template detect transclusion?

Is there a simple way for a template to detect whether it was invoked directly from the main name space, or whether it was invoked by way of one or more intermediate templates?