Implement loop detection for cluster links.

Refs #5467