correct pattern tree construction