private void checkCycles(Dimension dim){
  List<DimensionPK> check=new ArrayList<DimensionPK>();
  Dimension child=dim;
  check.add(child.getId());
  Dimension parent=getParent(child);
  while (parent != null) {
    if (check.contains(parent.getId())) {
      sanitizeParent(child);
      break;
    }
 else {
      child=parent;
      check.add(child.getId());
      parent=getParent(child);
    }
  }
}

private void checkCycles ( Dimension dim ) { List < DimensionPK > check = new ArrayList < DimensionPK > ( ) ; Dimension child = dim ; check . add ( child . getId ( ) ) ; Dimension parent = getParent ( child ) ; while ( parent != null ) { if ( check . contains ( parent . getId ( ) ) ) { sanitizeParent ( child ) ; break ; } else { child = parent ; check . add ( child . getId ( ) ) ; parent = getParent ( child ) ; } } }
check for cycles by starting to iterate from the given dimension . if we find a cycle , it will sanitize the relationship .
