public static Stella_Object justificationArgumentBoundTo(Stella_Object argument, Justification justification) {
    if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(argument), Logic.SGT_LOGIC_PATTERN_VARIABLE)) {
      { PatternVariable argument000 = ((PatternVariable)(argument));

        if (justification == null) {
          justification = ((Justification)(Logic.$CURRENTJUSTIFICATION$.get()));
        }
        if (justification != null) {
          { Justification pattern = ((justification.inferenceRule == Logic.KWD_PATTERN) ? justification : justification.patternJustification);
            KeyValueMap substitution = ((pattern != null) ? pattern.substitution : ((KeyValueMap)(null)));
            Stella_Object value = null;

            if (substitution != null) {
              value = substitution.lookup(argument000);
            }
            if ((value == null) &&
                (pattern != null)) {
              pattern = pattern.patternJustification;
              if (pattern != null) {
                value = Logic.justificationArgumentBoundTo(argument000, pattern);
              }
            }
            return (value);
          }
        }
      }
    }
    else {
      return (argument);
    }
    return (null);
  }