Assuming that r is the root of a tree (may be non-binary), c is a child of r, and each node contains an integer.
Algorithm findMax(r)
if r = null return null
int maxValue = r.value
if r.isLeaf return maxValue;
for each child c of r do{
if findMax(c) > maxValue
maxValue = findMax(c)
}
return maxValue
maxValue = findMax(c)andif findMax(c) > maxValue?