Identifying first and last instance of shortcode in post

Basically, nested shortcodes should not be used. As you say it ends as being too complex for an author to write one and therefor it will be too complex to understand and modify.

A better approach to such things is either insert a menu with a shortcode, or generate the accordion dynamically based on a specific HTML element (h2 for example)

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)