Basic flattening for pattern match reconstruction