void setCodeValues(HTreeNode root){
    
    /* Does nothing if root node is null. */
    if (root == null)
      return;
    
    /* Checks if the root is null. */
    if (root != null)
    {  
      /* Checks if the left subtree is null. */
      if (root.getLeft() != null)
        
        /* Set code of left subtree node to 0. */
        root.getLeft().setCode(0);
      
      /* Explore the left subtree. */
      setCodeValues(root.getLeft());
      
      /* Checks if the right subtree is null. */
      if (root.getRight() != null)  
        
        /* Set code of right subtree node to 1. */
        root.getRight().setCode(1);
      
      /* Explore the right subtree. */
      setCodeValues(root.getRight());
      
      /* Checks if both subtrees are null. */
      if (root.isLeafNode())
        return;
    }      
  }