SELECT COUNT(DISTINCT `ezcontentobject`.`id`)
FROM   `ezcontentobject`
       INNER JOIN ezcontentobject_version
               ON ezcontentobject.id = ezcontentobject_version.contentobject_id
       LEFT JOIN `ezcontentobject_tree` AS `sort_table_0`
              ON `sort_table_0`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818bb5ba`
              ON `53a16818bb5ba`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818bbb64`
              ON `53a16818bbb64`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818bc175`
              ON `53a16818bc175`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818bc91f`
              ON `53a16818bc91f`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818bcd06`
              ON `53a16818bcd06`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818bd4b2`
              ON `53a16818bd4b2`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818bf7dc`
              ON `53a16818bf7dc`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818bffbd`
              ON `53a16818bffbd`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818c077a`
              ON `53a16818c077a`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818c1335`
              ON `53a16818c1335`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818c1b04`
              ON `53a16818c1b04`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818c1ee3`
              ON `53a16818c1ee3`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818c26cd`
              ON `53a16818c26cd`.`contentobject_id` = `ezcontentobject`.`id`
       LEFT JOIN `ezcontentobject_tree` AS `53a16818c2e93`
              ON `53a16818c2e93`.`contentobject_id` = `ezcontentobject`.`id`
WHERE  ( ( `ezcontentobject`.`id` IN (SELECT `contentobject_id`
                                      FROM   `ezcontentobject_tree`
                                      WHERE  `parent_node_id` IN ( 4709091 ))
           AND `ezcontentobject`.`contentclass_id` IN
               (SELECT `id`
                FROM   `ezcontentclass`
                WHERE  `identifier` IN ( 'chapter' ))
           AND ( `ezcontentobject`.`contentclass_id` IN ( '76' )
                  OR ( `ezcontentobject`.`contentclass_id` IN ( '33' )
                       AND `ezcontentobject`.`section_id` IN ( '5' ) )
                  OR `ezcontentobject`.`contentclass_id` IN ( '76', '15' )
                  OR ( ( `53a16818bb5ba`.`path_string` LIKE '/1/2/220/124/%'
                          OR `53a16818bb5ba`.`path_string` LIKE '/1/2/220/143/%'
                          OR `53a16818bb5ba`.`path_string` LIKE '/1/2/220/538/%'
                          OR `53a16818bb5ba`.`path_string` LIKE '/1/2/220/65/%'
                          OR `53a16818bb5ba`.`path_string` LIKE '/1/2/220/68/%'
                          OR `53a16818bb5ba`.`path_string` LIKE '/1/2/220/95/%'
                       )
                       AND `ezcontentobject`.`contentclass_id` IN ( '49' )
                       AND `ezcontentobject`.`section_id` IN ( '1' ) )
                  OR ( `53a16818bbb64`.`path_string` LIKE '/1/43/51/%'
                       AND `ezcontentobject`.`contentclass_id` IN ( '59' ) )
                  OR ( `53a16818bc175`.`path_string` LIKE '/1/2/2853107/%'
                       AND `ezcontentobject`.`contentclass_id` IN ( '1' ) )
                  OR ( `ezcontentobject`.`contentclass_id` IN ( '54' )
                       AND `ezcontentobject`.`owner_id` IN ( 2597581 ) )
                  OR ( ( `53a16818bc91f`.`path_string` LIKE '/1/2/219/2852823/%'
                          OR `53a16818bc91f`.`path_string` LIKE
                             '/1/2/219/2852832/%'
                          OR `53a16818bc91f`.`path_string` LIKE
                             '/1/2/219/2853175/%' )
                       AND `ezcontentobject`.`contentclass_id` IN ( '1' ) )
                  OR ( ( `53a16818bcd06`.`path_string` LIKE '/1/2/219/2852823/%'
                          OR `53a16818bcd06`.`path_string` LIKE
                             '/1/2/219/2852832/%'
                          OR `53a16818bcd06`.`path_string` LIKE
                             '/1/2/219/2853175/%' )
                       AND `ezcontentobject`.`contentclass_id` IN ( '1' ) )
                  OR `ezcontentobject`.`contentclass_id` IN (
                     '53', '132', '127', '124',
                     '23', '119', '33', '114',
                     '116', '115', '64', '139',
                     '66', '125', '123', '118',
                     '49', '31', '120', '36' )
                  OR ( ( `53a16818bd4b2`.`path_string` LIKE
                         '/1/2/219/77/2526561/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/251/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/252/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/253/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/255/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/256/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/257/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/259/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/260/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/262/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/264/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/266/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/269/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/14080/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/270/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/2526451/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/2526471/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/2526481/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/79/2526511/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/78/1632/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/78/241/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/78/242/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/78/243/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/78/244/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/78/245/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/78/246/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/78/247/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/78/250/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/3265191/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/2204/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/222/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/224/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/226/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/227/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/228/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/230/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/231/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/233/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/235/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/239/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/240/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/2526521/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/2526531/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/2526541/%'
                          OR `53a16818bd4b2`.`path_string` LIKE
                             '/1/2/219/77/2526551/%'
                       )
                       AND ( ( `ezcontentobject`.`contentclass_id` IN ( '50' )
                               AND `ezcontentobject`.`section_id` IN ( '9' ) )
                              OR ( `ezcontentobject`.`contentclass_id` IN (
                                   '122', '126', '28', '31',
                                   '48', '57', '59' )
                                   AND `ezcontentobject`.`id` IN (SELECT
                                       `contentobject_id`
                                                                  FROM
                                       `ezcobj_state_link`
                                                                  WHERE
                                       `contentobject_state_id` IN ( '3'
                                       ))
                                 )
                              OR `ezcontentobject`.`contentclass_id` IN (
                                 '117', '1', '133', '112', '131' ) ) )
                  OR ( ( `53a16818bf7dc`.`path_string` LIKE
                         '/1/2/219/2852823/2852824/2853192/%'
                          OR `53a16818bf7dc`.`path_string` LIKE
                             '/1/2/219/2852823/2852826/2853193/%'
                          OR `53a16818bf7dc`.`path_string` LIKE
                             '/1/2/219/2852823/2852824/2852827/%'
                          OR `53a16818bf7dc`.`path_string` LIKE
                             '/1/2/219/2852823/2852826/2853194/%'
                           )
                       AND ( `ezcontentobject`.`contentclass_id` IN (
                             '113', '122', '129', '28',
                             '31', '48', '50', '57',
                             '59', '60', '65' )
                             AND `ezcontentobject`.`id` IN (SELECT
                                 `contentobject_id`
                                                            FROM
                                 `ezcobj_state_link`
                                                            WHERE
                                 `contentobject_state_id` IN ( '3'
                                 ))
                           ) )
                  OR ( ( `53a16818bffbd`.`path_string` LIKE '/1/2/219/79/%'
                          OR `53a16818bffbd`.`path_string` LIKE '/1/2/219/78/%'
                          OR `53a16818bffbd`.`path_string` LIKE '/1/2/219/77/%'
                       )
                       AND `ezcontentobject`.`contentclass_id` IN ( '50' ) )
                  OR ( `53a16818c077a`.`path_string` LIKE '/1/2/219/2852802/%'
                       AND ( ( `ezcontentobject`.`contentclass_id` IN (
                               '28', '31', '48', '57',
                               '58', '59' )
                               AND `ezcontentobject`.`id` IN (SELECT
                                   `contentobject_id`
                                                              FROM
                                   `ezcobj_state_link`
                                                              WHERE
                                   `contentobject_state_id` IN ( '3'
                                   )) )
                              OR `ezcontentobject`.`contentclass_id` IN
                                 ( '1', '50', '66', '67', '68' )
                           ) )
                  OR ( ( `53a16818c1335`.`path_string` LIKE
                         '/1/2/219/2852802/2852805/%'
                          OR `53a16818c1335`.`path_string` LIKE
                             '/1/2/219/2852802/2852804/%'
                          OR `53a16818c1335`.`path_string` LIKE
                             '/1/2/219/2852802/2852803/%' )
                       AND ( ( `ezcontentobject`.`contentclass_id` IN (
                               '28', '31', '48', '57',
                               '58', '59' )
                               AND `ezcontentobject`.`id` IN (SELECT
                                   `contentobject_id`
                                                              FROM
                                   `ezcobj_state_link`
                                                              WHERE
                                   `contentobject_state_id` IN ( '3'
                                   )) )
                              OR `ezcontentobject`.`contentclass_id` IN (
                                 '68', '1', '133', '67',
                                 '131', '66' ) ) )
                  OR ( `53a16818c1b04`.`path_string` LIKE '/1/2/542/1456/%'
                       AND ( ( `53a16818c1ee3`.`path_string` LIKE
                               '/1/2/542/1456/%'
                               AND `ezcontentobject`.`contentclass_id` IN ( '66'
                                   )
                               AND `ezcontentobject`.`owner_id` IN ( 2597581 ) )
                              OR ( `53a16818c26cd`.`path_string` LIKE
                                   '/1/2/542/1456/%'
                                   AND `ezcontentobject`.`contentclass_id` IN (
                                       '1' ) )
                           )
                     )
                  OR ( ( `53a16818c2e93`.`path_string` LIKE
                         '/1/2/219/2852832/2852932/2852956/%'
                          OR `53a16818c2e93`.`path_string` LIKE
                             '/1/2/219/2852832/2852932/2852947/%'
                           )
                       AND ( `ezcontentobject`.`contentclass_id` IN
                             ( '1', '112' )
                              OR ( `ezcontentobject`.`contentclass_id` IN (
                                   '57', '113', '48', '59' )
                                   AND `ezcontentobject`.`id` IN (SELECT
                                       `contentobject_id`
                                                                  FROM
                                       `ezcobj_state_link`
                                                                  WHERE
                                       `contentobject_state_id` IN ( '3'
                                       ))
                                 ) ) ) ) )
         AND ezcontentobject_version.status = 1 )