docs: private Set<Bean> flattenReferences(Bean bean) {
          Set<Bean> beans = new HashSet<>();
          for (String referenceName : bean.getReferenceNames()) {
              List<BeanId> ids = bean.getReference(referenceName);
              for (BeanId id : ids) {
                  if (id.getBean() == null) {
                      continue;
                  }
                  beans.addAll(flattenReferences(id.getBean()));
              }
          }
          beans.add(bean);
          return beans;
      }