Added equals and hashCode functionality to nodes for comparison