Fix parents

To do this more efficiently, I've modified the internal `traverseParents` function. This should resolve issue #317.