expansion: detect cyclic paths