Speed up ?root

- The original plan was to use the parent cache for this, but that's
  way too much work.  We can just pre-compute the set of roots when
  the predicate is constructed, and then just look inside in O(1).
  This approach is fully tolerable for ?root, as roots are few.