Since you count with n you can only pass n to one of the leafs or you can nest them like this:
public int traverseHelper(Node t, String key, int n) {
if (t == null) {
return n;
} else {
if (t.data.getTitle().indexOf(key) >= 0 && n <= 10) {
System.out.println(t.data);
n++;
}
return traverseHelper(t.left, key, traverseHelper(t.right, key, n));
}
}
Nesting like this reduces stack usage slightly since you don't have the extra adding and the left becomes a tail call. Java don't have tail call optimization but it doesn't hurt to write as if it had.