Modify setter methods to avoid formation of cycles

Both setLeftChild() and setRightChild() methods have been modified
and a "contains" check is done for the new node to be added before
actually adding it