<Purpose>
    Removes all commands found in a command dictionary from another command 
    dictionary. Remember to perform the same call on under the help node 
    so that the help command works as expected.
    
    e.g.
      remove_commanddict(seashcommanddict, mycommanddict)
      remove_commanddict(seashcommanddict['help']['children'], mycommanddict) 
    
  <Arguments>
    originaldict: The commanddict to remove from.
    removedict: The commanddict containing the commands to remove.
    
  <Side Effects>
    All commands in cmddict_merge will be removed from originaldict.
    A node will not be removed while there are children under that node.
    However, if a parent node is undefined and the last defined child is removed,
    that parent node will be removed as well.
    
  <Exceptions>
    None
  
  <Returns>
    None

def remove_commanddict(originaldict, removedict):
  """
  <Purpose>
    Removes all commands found in a command dictionary from another command 
    dictionary. Remember to perform the same call on under the help node 
    so that the help command works as expected.
    
    e.g.
      remove_commanddict(seashcommanddict, mycommanddict)
      remove_commanddict(seashcommanddict['help']['children'], mycommanddict) 
    
  <Arguments>
    originaldict: The commanddict to remove from.
    removedict: The commanddict containing the commands to remove.
    
  <Side Effects>
    All commands in cmddict_merge will be removed from originaldict.
    A node will not be removed while there are children under that node.
    However, if a parent node is undefined and the last defined child is removed,
    that parent node will be removed as well.
    
  <Exceptions>
    None
  
  <Returns>
    None
  """
  
  for child in removedict:
    if child in originaldict:
      # Recursively remove all children specified
      remove_commanddict(originaldict[child]['children'], removedict[child]['children'])
      # Remove the definition as well if it is defined in removedict
      if is_commanddictnode_defined(removedict[child]):
        # Remove everything except for children.  We remove those recursively.
        for propertytype in removedict[child]:
          # Not all properties (i.e. module) will be defined in the original 
          # dictionary.  We may raise an exception when trying to delete one
          # such property.
          if (propertytype != 'children' and
              propertytype in originaldict[child]):
            del originaldict[child][propertytype]
      # Remove this node if this node is no longer defined, and if there are no 
      # remaining child nodes.
      if not (is_commanddictnode_defined(originaldict[child]) or originaldict[child]['children']):
        del originaldict[child]