def unify(x, y, s):
if s is None:<EOL><INDENT>return None<EOL><DEDENT>elif x == y:<EOL><INDENT>return s<EOL><DEDENT>elif is_variable(x):<EOL><INDENT>return unify_var(x, y, s)<EOL><DEDENT>elif is_variable(y):<EOL><INDENT>return unify_var(y, x, s)<EOL><DEDENT>elif isinstance(x, Expr) and isinstance(y, Expr):<EOL><INDENT>return unify(x.args, y.args, unify(x.op, y.op, s))<EOL><DEDENT>elif isinstance(x, str) or isinstance(y, str):<EOL><INDENT>return None<EOL><DEDENT>elif issequence(x) and issequence(y) and len(x) == len(y):<EOL><INDENT>if not x: return s<EOL>return unify(x[<NUM_LIT:1>:], y[<NUM_LIT:1>:], unify(x[<NUM_LIT:0>], y[<NUM_LIT:0>], s))<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
Unify expressions x,y with substitution s; return a substitution that
    would make x,y equal, or None if x,y can not unify. x and y can be
    variables (e.g. Expr('x')), constants, lists, or Exprs. [Fig. 9.1]
    >>> ppsubst(unify(x + y, y + C, {}))
    {x: y, y: C}