code: def _get_entref(bpe):
          
          if not _is_reference(bpe):
              try:
                  er = bpe.getEntityReference()
              except AttributeError:
                  return None
              return er
          else:
              return bpe
docs: Returns the entity reference of an entity if it exists or
          return the entity reference that was passed in as argument.