Added solution for Is it a tree