def get_node_count(expr):
    """ Get the number of model expression nodes in an expression or list of expressions

    Args:
        expr:   Expression or list of expressions
    Returns:
        Total number of nodes
    """
    # Initialize stack of expressions to parse
    estack = []
    try:
        estack.extend(expr)
    except:
        estack.append(expr)
    doneset = set()  # Set of ids of expressions already processed

    # Loop while expression stack is not empty
    while estack:
        e = estack.pop()
        eid = id(e)
        if not eid in doneset:
            doneset.add(eid)
            # Stack children expressions
            try:
               estack.extend(e.children)
            except:
                pass

    return len(doneset)