• Ricu, by the looks of it, you are getting this error because your two triggers are causing each other to fire, this is never a good idea as it'll just keep looping round until it hits this limit.

    Is this a "one off" task you are wishing to do or is it something you are looking to maintain?

    One quick and dirty approach would be to set the foreign keys to be cascading deletes, this would deal with it but may have undesired results.

    Is there a maximum depth of parent child relationships?

    If you can give a bit more detail around what you are trying to do I'm sure I can give some help on how to achieve this, for example do you have a set of id values you wish to delete (i.e. your 0,1,2,3 example) or are these rules you are wishing to apply?