Detect more square patterns

As the one found in the benchmark `slowparts.py'