a super clean means of matching recursive patterns