left node child (NilNode in case of leaf)
left node child (NilNode in case of leaf)
right node child (NilNode in case of leaf) Note: this pattern is a bit unsual.
right node child (NilNode in case of leaf) Note: this pattern is a bit unsual. The good practice would be to define a Leaf object rather than a Nil (with null fields) but this solution speeds up processing as we don't need to match case classes when descending in the tree