Clean up parentWays, apply same algorithm to relations