`thePath.lastIndexOf(potentialParent, 0) === 0` is *O(1)* in the worst case.