docs: HasName findReference(String fullRefName, String enclosingNamespace)
      {
          boolean doneSearch = false;
  
          // Special case: if fullRefName begins with a period it is a fully qualified
          // name so just search for that (but strip off the initial dot!)
          if (fullRefName.charAt(0) == '.')
              return findFullyQualifiedObject(fullRefName.substring(1));
  
          // Search for the object in the enclosing namespace, as well as each parent
          // namespace until we find the object
          while (!doneSearch)
          {
              String searchName = (enclosingNamespace == null ? fullRefName : enclosingNamespace + '.' + fullRefName);
              HasName obj = findFullyQualifiedObject(searchName);
              if (obj != null)
                  return obj;
  
              // We didn't find the object. Strip off the last component of the
              // namespace and try again
              if (enclosingNamespace != null)
              {
                  int dotIndex = enclosingNamespace.lastIndexOf('.');
                  if (dotIndex < 0)
                      enclosingNamespace = null;
                  else
                      enclosingNamespace = enclosingNamespace.substring(0, dotIndex);
              }
              else
              {
                  doneSearch = true;
              }
          }
  
          // If we didn't find a match using the normal protobuf-compatible
          // lookup method, try searching each imported .proto as if we were
          // in their namespace
          for (Proto proto : getImportedProtos())
          {
              String searchName = (proto.getPackageName() == null ? fullRefName : proto.getPackageName() + '.'
                      + fullRefName);
              HasName result = proto.findFullyQualifiedObject(searchName);
              if (result != null)
                  return result;
          }
  
          // No results
          return null;
      }