Rewriting function finding pathlist for matching template.  Do not pull this.