     @_parent?.removeChild this
 
     for child in @_children
-      child.destroy()
+      child?.destroy()
 
     return @
 

  removeChild: (task) ->
    i = @_children.indexOf task
    if i > -1
      @_children.splice i, 1
      task._parent = null
    return @


    if @active
      @onUpdate? elapsedTime

      i = 0
      len = @_children.length
      while i < len
        child = @_children[i]
        if child?
          child.update elapsedTime
          i++
        else
          @_children.splice i, 1
          len--

    return @

