It should look something like the following:
select spf.folder_id,
...
from ((static_pages sp
RIGHT OUTER JOIN
(select folder_id,level as lev from sp_folders
start with folder_id = :root_folder_id
connect by parent_id = prior folder_id) spf ON spf.folder_id = sp.folder_id)
LEFT OUTER JOIN
acs_permissions p_file ON (p_file.grantee_id = acs__magic_object_id('the_public') and
p_file.privilege = 'general_comments_create' and
p_file.object_id = sp.static_page_id))
LEFT OUTER JOIN
acs_permissions p_folder ON (p_folder.grantee_id = acs__magic_object_id('the_public') and
p_folder.privilege = 'general_comments_create' and
p_folder.object_id = spf.folder_id)