And, correction, taking account for both lengths, `thePath.lastIndexOf(potentialParent, 0))` is *O(m)* where *m* is the length of the potentialParent, in the worst case, which happens to be any of the cases where the potential parent is in fact a parent.