A much more simpler version and a generalised version(works for all types of binary tree)