code: private void findReferences(ImmutableBean root) {
          // handle root bean
          classes.put(root.getClass(), classInfoFromMetaBean(root.metaBean(), root.getClass()));
          classSerializationCount.put(root.getClass(), 1);
  
          // recursively check object graph
          Map<Object, Integer> objects = new LinkedHashMap<>();
          findReferencesBean(root, root.getClass(), objects, null);
  
          // build up the list of references, but only for those instances that are repeated
          List<Map.Entry<Object, Integer>> refEntries = objects.entrySet().stream()
                  .sorted(reverseOrder(comparingInt(Map.Entry::getValue)))
                  .filter(entry -> entry.getValue() > 1)
                  .collect(toList());
          for (Map.Entry<Object, Integer> entry : refEntries) {
              Object value = entry.getKey();
              Class<?> realType = value.getClass();
  
              // simple types do not need references
              if (realType != Integer.class &&
                      realType != Double.class &&
                      realType != Float.class &&
                      realType != Boolean.class &&
                      realType != Long.class &&
                      realType != Short.class &&
                      realType != Byte.class &&
                      realType != byte[].class) {
  
                  refs.put(value, new Ref(false, refs.size()));
              }
          }
          
          // reorder classes so the most repeated serialized names have the lowest number (hence the shortest extension)
          this.classInfoList.addAll(classSerializationCount.entrySet().stream()
                  .sorted(reverseOrder(comparingInt(Map.Entry::getValue)))
                  .map(entry -> classes.get(entry.getKey()))
                  .collect(toList()));
  
          // adjust the position in the ClassInfo instance
          for (int position = 0; position < classInfoList.size(); position++) {
              ClassInfo classInfo = classInfoList.get(position);
              classInfo.position = position;
          }
      }
docs: finds classes and references within the bean