Added collapseWhitespace static function, used it on parseP