In overextends template tag, don't assume extends node is first in node list.