BEGIN highestAmount ( pNode)
DEFINE wordBST: pointer of RECORD wordNode;
DEFINE RECORD LetterNode
{
left: pointer of RECORD wordNode,
word: char,
counter: integer,
right: pointer of RECORD wordNode
}
DEFINE Q;
CreateQueue(Q);
SET wordBST to pNode;
SET Highest TO pNode -> counter;
WHILE (wordBST is not null)
process (wordBST)
IF (wordBST -> left is not null) THEN
ENQUEUE(Q, wordBST -> left)
ENDIF
IF (wordBST -> right is not null) THEN
ENQUEUE(Q, wordBST -> right)
ENDIF
IF (not isEmpty(Q));
IF (wordBST -> counter is greater than Highest) THEN
SET Highest TO wordBST -> counter;
ELSE
swapNode (wordBST, pNode);
ENDIF
SET wordBST to DEQUEUE (Q);
ELSE
SET wordBST to null
ENDIF
ENDWHILE
END highestAmount
the above is a pseudo code to traverse the binary tree to get the highest occurrence from a counter and output the word.