Source: https://www.sfu.ca/~mdevos/notes/graph/345_trees.pdf