public void insert(A a) {
    assert a != null;

    Match m = findMatch(a);

    if (m.matchFound) {
      m.node.contents = a;

      splay(m.node);
    } else {
      Node parent  = m.node;
      Node newNode = new Node(a);

      if (m.smallerThanNode) {
        parent.setLeft(newNode);
      } else {
        parent.setRight(newNode);
      }

      splay(newNode);
    }
  }