/**
 * Get the parent template instance.
 * @param {Number} [levels] How many levels to go up. Default is 1
 * @returns {Blaze.TemplateInstance}
 */
Blaze.TemplateInstance.prototype.parentTemplate = Blaze.TemplateInstance.prototype.parentInstance = function(levels) {
	let view = this.view;
	
	levels = (typeof levels === "undefined") ? 1 : levels;
	
	while(view) {
		//if(view.name.substring(0, 9) === "Template." && !(levels--)) {
		if(view.template && !(levels--)) {
			//return view.templateInstance();
			return view.templateInstance();
		}
		view = view.parentView;
	}
};