getTeminatorAt recurses infinitely if template is its own terminator

R=arv
BUG=

Review URL: https://codereview.appspot.com/9918043