stored procedure for duties with dead branches trimmed