The algorithm you’ll be using here is called Modified Preorder Tree Traversal - I am not sure if Yii has anything built-in, or an extension, but it should be straight forward to do this.
In my case each node (i.e. task) can have more than one parent nodes (i.e. task can have several tasks that should be done before), and each node can have more than one child nodes (i.e. several tasks can be done only after finishing this task), so I think I still need an additional table to map relations.