add method for finding statements matching a pattern