code: public static Field getField(final Class<?> clazz, final String fieldName) {
          //Define return type
          //
          Field
              field = null;
  
          //For each class in the hierarchy starting with the current class, try to find the declared field
          //
          for (Class<?> current = clazz; current != null && field == null; current = current.getSuperclass()) {
              try {
                  //Attempt to get the field, if exception is thrown continue to the next class
                  //
                  field =
                      current
                          .getDeclaredField(
                              fieldName
                          );
              }
              catch (final NoSuchFieldException e) {
                  //ignore and continue searching
                  //
              }
          }
  
          //Return the field we found
          //
          return
              field;
      }
docs: Climb the class hierarchy starting with the clazz provided, looking for the field with fieldName
  
  @param clazz starting class to search at
  @param fieldName name of the field we are looking for
  @return Field which was found, or null if nothing was found