public Optional<ImmutableSubstitution<? extends VariableOrGroundTerm>> normalizeDescendingSubstitution(
            IQTree tree, ImmutableSubstitution<? extends VariableOrGroundTerm> descendingSubstitution)
            throws UnsatisfiableDescendingSubstitutionException {

        ImmutableSubstitution<? extends VariableOrGroundTerm> reducedSubstitution = descendingSubstitution
                .reduceDomainToIntersectionWith(tree.getVariables());

        if (reducedSubstitution.isEmpty())
            return Optional.empty();

        if (reducedSubstitution.getImmutableMap().values().stream().anyMatch(value ->
                value.equals(termFactory.getNullConstant()))) {
            throw new UnsatisfiableDescendingSubstitutionException();
        }

        return Optional.of(reducedSubstitution);
    }
public Optional < ImmutableSubstitution < ? extends VariableOrGroundTerm > > normalizeDescendingSubstitution ( IQTree tree , ImmutableSubstitution < ? extends VariableOrGroundTerm > descendingSubstitution ) throws UnsatisfiableDescendingSubstitutionException { ImmutableSubstitution < ? extends VariableOrGroundTerm > reducedSubstitution = descendingSubstitution . reduceDomainToIntersectionWith ( tree . getVariables ( ) ) ; if ( reducedSubstitution . isEmpty ( ) ) return Optional . empty ( ) ; if ( reducedSubstitution . getImmutableMap ( ) . values ( ) . stream ( ) . anyMatch ( value -> value . equals ( termFactory . getNullConstant ( ) ) ) ) { throw new UnsatisfiableDescendingSubstitutionException ( ) ; } return Optional . of ( reducedSubstitution ) ; }
Excludes the variables that are not projected by the IQTree

If a "null" variable is propagated down, throws an UnsatisfiableDescendingSubstitutionException.