The algorithm should be something like this:

Code:

public int MaxBranch(node node){
int length = 0;
int lengthMax = 0;
TestChild (node, length, lengthMax);
return lengthMax
}
public int TestChild (node node, int length, int lengthMax){
if (node.l(n) != null){
length = length ++;
TestChild (node.l(n), length, lengthMax);
}
if (length > lengthMax){
lengthMax = length;
}
if (node.r(n) != null){
length = length ++;
TestChild (node.r(n), length, lengthMax);
}
if (length > lengthMax){
lengthMax = length;
}
return lengthMax;
}

Not 100%, but I hope that helps you visualise at least. Basically, you test if there is a left-node, if there is you add one to the length and then test if that node has a left node.....once you get a no, you compare that length to the greatest length so far; then check for right node etc.

It's recursively calling itself within the algorithm.

Hope that helps.