Traitor burl kills me in "vital help" level

I’m trying to 100% complete the level “vital help“, but my own burl keeps killing me for some reason. Videofiles are not supported so here is a link to a google drive folder: burl-kills-me-vid - Google Drive

also here is my entire code (removed commented code given by level for better reading):

def pickUpNearestCoin():
    items = hero.findItems()
    nearestCoin = hero.findNearest(items)
    if nearestCoin:
        hero.move(nearestCoin.pos)

def summonSoldier():
    if hero.gold >= hero.costOf("soldier"):
        hero.summon("soldier")
    pass


def commandSoldiers():
    for soldier in hero.findByType("soldier"):
        enemy = soldier.findNearestEnemy()
        if enemy:
            hero.command(soldier, "attack", enemy)

while True:
    enemy = hero.findNearestEnemy()
    if enemy and hero.distanceTo(enemy) <= 5:
        hero.cast("drain-life", enemy)
    if hero.isReady("summon-burl"):
        hero.cast("summon-burl")
    if hero.isReady("summon-undead"):
        hero.cast("summon-undead")
        if hero.isReady("reset-cooldown"):
            hero.resetCooldown("summon-undead")
            hero.cast("summon-undead")
    if hero.time > 20:
        if hero.isReady("raise-dead"):
            hero.cast("raise-dead")
    if hero.time > 40:
        hero.move({"x":42,"y":38})
        if hero.isReady("throw-charge"):
            hero.throwCharge(10)
        else:
            if enemy and hero.distanceTo(enemy) >= 15:
                hero.cast("drain-life", enemy)
    if hero.time < 40:
        pickUpNearestCoin()
    summonSoldier()
    commandSoldiers()

i think my burl might have some anger issues and should go to a psychologist, but i posted this to check for any alternative causes and solutions