void addNodes(List<Node> newNodes,boolean atBeginning){
  if (atBeginning) {
    if ((nodes.size() > 0) && nodes.get(0) == newNodes.get(newNodes.size() - 1)) {
      Log.i(DEBUG_TAG,"addNodes attempt to add same node");
      if (newNodes.size() > 1) {
        Log.i(DEBUG_TAG,"retrying addNodes");
        newNodes.remove(newNodes.size() - 1);
        addNodes(newNodes,atBeginning);
      }
      return;
    }
    nodes.addAll(0,newNodes);
  }
 else {
    if ((nodes.size() > 0) && newNodes.get(0) == nodes.get(nodes.size() - 1)) {
      Log.i(DEBUG_TAG,"addNodes attempt to add same node");
      if (newNodes.size() > 1) {
        Log.i(DEBUG_TAG,"retrying addNodes");
        newNodes.remove(0);
        addNodes(newNodes,atBeginning);
      }
      return;
    }
    nodes.addAll(newNodes);
  }
}

void addNodes ( List < Node > newNodes , boolean atBeginning ) { if ( atBeginning ) { if ( ( nodes . size ( ) > 0 ) && nodes . get ( 0 ) == newNodes . get ( newNodes . size ( ) - 1 ) ) { Log . i ( DEBUG_TAG , "addNodes attempt to add same node" ) ; if ( newNodes . size ( ) > 1 ) { Log . i ( DEBUG_TAG , "retrying addNodes" ) ; newNodes . remove ( newNodes . size ( ) - 1 ) ; addNodes ( newNodes , atBeginning ) ; } return ; } nodes . addAll ( 0 , newNodes ) ; } else { if ( ( nodes . size ( ) > 0 ) && newNodes . get ( 0 ) == nodes . get ( nodes . size ( ) - 1 ) ) { Log . i ( DEBUG_TAG , "addNodes attempt to add same node" ) ; if ( newNodes . size ( ) > 1 ) { Log . i ( DEBUG_TAG , "retrying addNodes" ) ; newNodes . remove ( 0 ) ; addNodes ( newNodes , atBeginning ) ; } return ; } nodes . addAll ( newNodes ) ; } }
adds multiple nodes to the way in the order in which they appear in the list . they can be either prepended or appended to the existing nodes .
