code: private static ImmutableTerm tryToExtractIRITemplateString(ImmutableTerm term) {
          if (term instanceof ImmutableFunctionalTerm) {
              ImmutableFunctionalTerm functionalTerm = (ImmutableFunctionalTerm) term;
              return functionalTerm.getArity() > 0
                      ? tryToExtractIRITemplateString(functionalTerm.getTerm(0))
                      : term;
          }
          return term;
      }
docs: TODO: refactor this weak code!!!