Generic Tree in Java My implementation of generic Tree structure: 

/**
 * Tree data structure
 */
public class Tree&lt;T&gt; {

    private T value;

    private Tree&lt;T&gt; parent;

    protected List&lt;Tree&lt;T&gt;&gt; children = Collections.emptyList();

    public Tree(T value) {
        this.value = value;
    }

    public Tree() {
    }

    /**
     * @return the value
     */
    public T getValue() {
        return value;
    }

    /**
     * @param value
     *            the value to set
     */
    public void setValue(T value) {
        this.value = value;
    }

    /**
     * Adds children
     * 
     * @param children
     * @return this
     */
    public final Tree&lt;T&gt; addChildren(List&lt;Tree&lt;T&gt;&gt; newChildren) {

        if (children == Collections.EMPTY_LIST) {
            children = new ArrayList&lt;&gt;();
        }

        for (Tree&lt;T&gt; child : newChildren) {
            if (children.add(child)) {
                child.setParent(this);
            }
        }
        return this;
    }

    /**
     * Adds children
     * 
     * @param children
     * @return this
     */
    @SafeVarargs
    public final Tree&lt;T&gt; addChildren(Tree&lt;T&gt;... children) {
        return addChildren(Arrays.asList(children));
    }

    /**
     * Removes children
     * 
     * @param children
     * @return this
     */
    public final Tree&lt;T&gt; removeChildren(List&lt;Tree&lt;T&gt;&gt; children) {
        for (Tree&lt;T&gt; child : children) {
            if (this.children.remove(child)) {
                child.setParent(null);
            }
        }
        return this;
    }

    /**
     * Removes children
     * 
     * @param children
     * @return this
     */
    @SafeVarargs
    public final Tree&lt;T&gt; removeChildren(Tree&lt;T&gt;... children) {
        return removeChildren(Arrays.asList(children));
    }

    /**
     * @return the parent
     */
    public Tree&lt;T&gt; getParent() {
        return parent;
    }

    /**
     * @param parent
     *            the parent to set
     */
    public void setParent(Tree&lt;T&gt; parent) {
        this.parent = parent;
    }

    /**
     * @return the tree root
     */
    public Tree&lt;T&gt; getRoot() {
        return parent == null ? this : parent.getRoot();
    }

    /**
     * @return children
     */
    public final List&lt;Tree&lt;T&gt;&gt; getChildren() {
        return children;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        buildString(sb, "", true);
        return sb.toString();
    }

    private void buildString(StringBuilder sb, String prefix, boolean isTail) {
        sb.append(prefix).append(isTail ? "└── " : "├── ").append(getValue()).append(System.lineSeparator());
        prefix += (isTail ? "    " : "│   ");

        for (int i = 0; i &lt; children.size(); i++) {
            children.get(i).buildString(sb, prefix, (i == children.size() - 1));
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (!(obj instanceof Tree&lt;?&gt;))
            return false;

        Tree&lt;?&gt; other = (Tree&lt;?&gt;) obj;

        if (this.children.size() != other.children.size())
            return false;

        for (int i = 0; i &lt; this.children.size(); i++) {
            if (!(children.get(i).equals(other.children.get(i))))
                return false;
        }

        return true;
    }

}


Any suggestions to make this better?
Your use of generics may be limiting. You may want to consider using the extends/super keywords to allow subtypes in the tree.
The Tree class should be final.
Perhaps TreeNode is a better name? Conceptually, it's a node, not a tree.
The children instance variable should be private. There's also no reason to use Collections.emptyList(). Just assign it to be a new ArrayList. You should really consider using a LinkedList, because you're not really doing random access on the list.
addChildren(List) should be addChildren(Collection). Sets need love, too. Whether the order is important or not should be left up to the client.
Your documentation for addChildren() and removeChildren() should make it clear that they modify the incoming children as a side effect.
It's not at all clear to me that it's desirable to return this from addChildren() and removeChildren(), but you certainly know more than I do about client needs.
setParent() needs to be private, or a client is going to change it manually and break your internals. Specifically, the node that used to be the parent will still have a reference to the node that just got its parent changed - you'll have two different one-way relationships, such that X's parent does not have X as its child.
getChildren() needs to return a (preferably immutable) copy of the children list, not the list itself. Otherwise a client can call removeAll() on the response and your internals are broken.
If you override equals(), you should also override hashCode(), or you may see strange behaviours, especially with collections. Are you sure you really need equals()?
The tree is thread-hostile. That is probably okay, given that this is most likely not production code, but it's something to be aware of.