def _ExtractObsoleteNode(node, recursive=True):
  """Extracts obsolete child from |node|. Returns None if not exists."""
  if not recursive:
    obsolete = [
        element for element in node.getElementsByTagName('obsolete')
        if element.parentNode == node
    ]
  else:
    obsolete = node.getElementsByTagName('obsolete')
  if not obsolete:
    return None
  assert len(obsolete) == 1, (
      'Node %s should at most contain one obsolete node.' %
      node.getAttribute('name'))
  return obsolete[0]