public static PostingsList andMerge(PostingsList posting1,
			PostingsList posting2) {
		PostingsList merged = new PostingsList();

		if (posting1 != null && posting2 != null && posting1.size() > 0
				&& posting2.size() > 0) {

			Node p1 = posting1.head;
			Node p2 = posting2.head;

			while (p1 != null && p2 != null) {
				if (p1.docID() == p2.docID()) {
					// we found a match, so add it to the list
					merged.addDoc(p1.docID());
					p1 = p1.next();
					p2 = p2.next();
				} else if (p1.docID() < p2.docID()) {
					// move up p1
					p1 = p1.next();
				} else {
					// move up p2
					p2 = p2.next();
				}
			}
		}

		return merged;
	}