code: private static List<List<Chain>> splitNonPolyChain(Chain chain) {
  		List<Chain> splitNonPolys = new ArrayList<>();
  		List<Chain> waterChains = new ArrayList<>();
  
  		Chain split = null;
  		boolean previousGroupIsWater = false;
  
  		for (Group g:chain.getAtomGroups()){
  
  			if (!previousGroupIsWater) {
  				// add last one if there's one
  				if (split!=null) {
  					splitNonPolys.add(split);
  				}
  				split = new ChainImpl();
  				split.setName(chain.getName());
  			} else if (!g.isWater()) {
  				// previous group is water and this group is not water: we change from a water chain to a non-poly
  				// we'll need to add now the water chain to the list of water chains
  				waterChains.add(split);
  				split = new ChainImpl();
  				split.setName(chain.getName());
  			}
  
  			if (g.isWater()) {
  				previousGroupIsWater = true;
  			} else {
  				previousGroupIsWater = false;
  
  			}
  
  			// this should include alt locs (referenced from the main group)
  			split.addGroup(g);
  
  		}
  
  		// adding the last split chain: either to water or non-poly depending on what was the last seen group
  		if (split!=null) {
  			if (previousGroupIsWater)
  				waterChains.add(split);
  			else
  				splitNonPolys.add(split);
  		}
  
  
  		List<List<Chain>> all = new ArrayList<>(2);
  		all.add(splitNonPolys);
  		all.add(waterChains);
  
  		return all;
  	}
docs: Split the given chain (containing non-polymer groups and water groups only)
  into individual chains per non-polymer group and individual chains per contiguous sets of water groups.
  @param chain
  @return a list of lists of size 2: first list is the split non-poly chains, second list is the split water chains