tg: consolidate contained_by
The "contained_by" function works like --is-ancestor except that
while it's never slower it's often slightly faster.
It has, however, proliferated all over the place.
One of the locations is tg.sh.
Therefore just eliminate the duplicates since they define the
same function and are totally unnecessary.
Also fix up one place that wasn't calling the function, but
was actually doing the same thing, to call the function instead.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>