private boolean hasLoop(int parentCategoryId,Vector<SimpleTreeNode> categories,int loopIndicatorId){
  final Iterator<SimpleTreeNode> iter=categories.iterator();
  boolean ret=false;
  while (iter.hasNext()) {
    SimpleTreeNode node=(SimpleTreeNode)iter.next();
    if (node.getNodeId() == parentCategoryId) {
      if (node.getParentId() == 0) {
        return false;
      }
      if (node.getNodeId() == loopIndicatorId) {
        return true;
      }
      ret=hasLoop(node.getParentId(),categories,loopIndicatorId);
    }
  }
  return ret;
}

private boolean hasLoop ( int parentCategoryId , Vector < SimpleTreeNode > categories , int loopIndicatorId ) { final Iterator < SimpleTreeNode > iter = categories . iterator ( ) ; boolean ret = false ; while ( iter . hasNext ( ) ) { SimpleTreeNode node = ( SimpleTreeNode ) iter . next ( ) ; if ( node . getNodeId ( ) == parentCategoryId ) { if ( node . getParentId ( ) == 0 ) { return false ; } if ( node . getNodeId ( ) == loopIndicatorId ) { return true ; } ret = hasLoop ( node . getParentId ( ) , categories , loopIndicatorId ) ; } } return ret ; }
recursive search for parent nodes - climbs the to the root . if there is a circle there is no root but it comes back to the start node .
