code: public static Object removeReference(List l, Object o) {
      Iterator iter = l.iterator();
      while (iter.hasNext()) {
        Object no = iter.next();
        if (no == o) {
          iter.remove();
          return o;
        }
      }
      return null;
    }
docs: Remove the object o from the list l. Different from l.remove(o)
  because this method only removes it if it is the same object
  @param l the list to remove from
  @param o the object to remove
  @return removed object if it was found in the list, null otherwise