Fixes check in _can_fast_union.

Fixes #4564.