more efficient path class
optimized for contains() and last()