Python Structural Pattern Analysis