Tree as an implementation of Java collection