Next up, let's implement add
.

A word is passed into the method (let's say "cat"
), and begins to get processed. We'll first want to have references to the head node so that we can include each letter in cat
as its eventual children and grandchildren. Here's how we accomplish establishing this lineage:
1Node currentNode = this.head;
2Node newNode = null;
3String currentChar = val.substring(0, 1);
4
5// val is used to keep track of the remaining letters
6val = val.substring(1);