Cache root ID for nested sets table

The root ID of a nested sets table is highly unlikely to change within a single page load of the site. When there are potentially multiple queries being executed to determine the root ID, this can become redundant work on a popular tree. To avoid this, once we have determined the root ID for a given table-key combination, the code will cache it internally and return that later reducing the number of times that redundant queries need to be executed.

JoomlaCode Issue Tracker: https://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33187&start=0