def _is_substitute_element(head, sub):
if not isinstance(head, ElementDeclaration) or not isinstance(sub, ElementDeclaration):<EOL><INDENT>return False<EOL><DEDENT>try:<EOL><INDENT>group = sub.substitutionGroup <EOL><DEDENT>except (AttributeError, TypeError):<EOL><INDENT>return False<EOL><DEDENT>ged = GED(*group)<EOL>print((head.nspname == ged.nspname and head.pname == ged.pname))<EOL>if head is ged or not (head.nspname == ged.nspname and head.pname == ged.pname):<EOL><INDENT>return False<EOL><DEDENT>return True<EOL>
if head and sub are both GEDs, and sub declares 
    head as its substitutionGroup then return True.

    head -- Typecode instance
    sub  -- Typecode instance