code: private static boolean compareOrderedCollection(Collection col1, Collection col2, Deque stack, Set visited)
      {
          // Same instance check already performed...
  
          if (col1.size() != col2.size())
          {
              return false;
          }
  
          Iterator i1 = col1.iterator();
          Iterator i2 = col2.iterator();
  
          while (i1.hasNext())
          {
              DualKey dk = new DualKey(i1.next(), i2.next());
              if (!visited.contains(dk))
              {   // push contents for further comparison
                  stack.addFirst(dk);
              }
          }
          return true;
      }
docs: Deeply compare two Collections that must be same length and in same order.
  @param col1 First collection of items to compare
  @param col2 Second collection of items to compare
  @param stack add items to compare to the Stack (Stack versus recursion)
  @param visited Set of objects already compared (prevents cycles)
  value of 'true' indicates that the Collections may be equal, and the sets
  items will be added to the Stack for further comparison.