I am trying to write a simplify the algorithm of finding the number of nodes in a binary tree by using good object oriented design. I have been into good OOP style recently and found it really compelling in way that it can simplify the mental load by proper polymorphism.Having said that, I don't know if it's a right strategy to follow in the interview since it may take some time to get to a good design.import java.util.*;import java.lang.*;import java.io.*;interface Node {    public int count();}class Empty implements Node {    public int count() {        return 0;    }}class NonEmpty<Item> implements Node {    private final Item item;    private final Node left;    private final Node right;    NonEmpty(Item item) {        this(item, new Empty(), new Empty());    }    NonEmpty(Item item, Node left, Node right) {        this.item = item;        this.left = left;        this.right = right;    }    public int count() {        return left.count() + right.count() + 1;    }}/* Name of the class has to be Main only if the class is public. */class Main{    public static void main (String[] args) throws java.lang.Exception    {        Node n = new Empty();        System.out.println(n.count()); // 0        // Single node tree        n = new NonEmpty(5);                    System.out.println(n.count()); // 1        // Complete Full tree               n = new NonEmpty(5, new NonEmpty(2), new NonEmpty(6));        System.out.println(n.count()); // 3        // Right skewed        n = new NonEmpty(5, new NonEmpty(2, new NonEmpty(6), new Empty()), new Empty());        System.out.println(n.count()); // 3    }}I am thinking to write some common Tree based algorithm this way and see how far I can go.Questions:Is this a good strategy for interviews?Have I divided the responsibility correctly?Does this scale well to other tree-based algorithms?Major Doubt:I have seen in books such as this the author focuses on different classes like for above it could be:class CountNodes {  public CountNodes(Node n) {    //...  }}Which is a better strategy? 
Count number of nodes in a binary tree the OO way
java;algorithm;object oriented;tree