Source: http://www.cs.cornell.edu/courses/cs211/2004sp/handout/lecture19moretrees.pdf