Please refer to my earlier question related to multi level insert with an extra condition.