When instantiating the PatternExtraction class, pass the TreeNodeCollection of the BODY TreeNode. There is no need to check for instances in the HEAD TreeNode.