def addChildIfNotPresent(node, childTag, childNode):
  """Add childNode with childTag to node, if no child with that tag is present.
  
  Returns the childNode of node with tag childTag.
  """
  for child in node:
    if child.tag == childTag:
      return child
  
  # No match. Add a child.
  node.append(childNode)
  return childNode