[!!!][BUGFIX] Prefer root templates for template evaluation

The Core always tries to use the first template according to their
sorting on a page. This totally ignores the root-flag of a template.

Change the evaluation to give root templates precedence over
extension templates independent of the sorting.

Resolves: #19737
Releases: master
Change-Id: I78948d8bde4d373bc5b26eb912d1789fc74bbbb1
Reviewed-on: http://review.typo3.org/34319
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>