def get_valid_example_ids(example_ids, global_ids, incremental = None):
   """func({example_ids}, {global_ids}, bool) -> [valid_identifiers]

   Compares the dictionary of a source example with all its possible
   identifiers against the dictionary with all the available
   documentation identifiers and returns a filtered list of the
   example identifiers which are also in the global dictionary.

   If the incremental parameter is true, the identifiers of
   global_ids that are also contained in example_ids will be
   erased. This is useful if you are building example after example
   and you don't want new lists to include the identifiers returned
   in previous calls to this function.
   """
   example_ids = example_ids.keys()
   example_ids.sort()
   valid_ids = []
   if incremental:
      for id in example_ids:
         try:
            del global_ids[id]
            valid_ids.append(id)
         except KeyError:
            pass
   else:
      for id in example_ids:
         if global_ids.has_key(id):
            valid_ids.append(id)
   return valid_ids