docs: @SuppressWarnings("unchecked")
      public static <F,T> Expression getJoinedEntityField(From<?, F> grandparentJoin, Attribute<?, T> parentJoinAttr, SingularAttribute fieldAttr) {
          // task -> * -> origJoin -> (fieldParentAttr field in) tojoinType ->  fieldAttr
  
          Class toAttrJoinType;
          if( parentJoinAttr instanceof SingularAttribute ) {
              toAttrJoinType = parentJoinAttr.getJavaType();
          } else if( parentJoinAttr instanceof PluralAttribute ) {
              toAttrJoinType = ((PluralAttribute) parentJoinAttr).getElementType().getJavaType();
          } else {
              String joinName = parentJoinAttr.getDeclaringType().getJavaType().getSimpleName() + "." + parentJoinAttr.getName();
              throw new IllegalStateException("Unknown attribute type encountered when trying to join " + joinName );
          }
  
          Join<F, T> fieldParentJoin = null;
          for( Join<F, ?> join : grandparentJoin.getJoins() ) {
             if( join.getJavaType().equals(toAttrJoinType) ) {
                if( join.getAttribute().equals(parentJoinAttr) )  {
                    fieldParentJoin = (Join<F, T>) join;
                    if( ! JoinType.INNER.equals(fieldParentJoin.getJoinType()) ) {
                        // This a criteria set by the user (as opposed to the user-limiting criteria) -- it MUST be followed
                        // This means that the join is not optional (LEFT) but mandatory (INNER)
                        fieldParentJoin = null;
                    }
                    break;
                }
             }
          }
          if( fieldParentJoin == null ) {
              if( parentJoinAttr instanceof SingularAttribute) {
                  fieldParentJoin = grandparentJoin.join((SingularAttribute) parentJoinAttr);
              } else if( parentJoinAttr instanceof CollectionAttribute) {
                  fieldParentJoin = grandparentJoin.join((CollectionAttribute) parentJoinAttr);
              } else if( parentJoinAttr instanceof ListAttribute) {
                  fieldParentJoin = grandparentJoin.join((ListAttribute) parentJoinAttr);
              } else if( parentJoinAttr instanceof SetAttribute) {
                  fieldParentJoin = grandparentJoin.join((SetAttribute) parentJoinAttr);
              } else {
                  throw new IllegalStateException("Unknown attribute type encountered when trying to join" + parentJoinAttr.getName() );
              }
          }
          return fieldParentJoin.get(fieldAttr);
      }