Chain decompositioin on tree (or graph)

Could anyone give me a tutorial or a code that does chain decomposition on any kind of tree (by using DFS)?