def _nodes(e):
 from .basic import Basic
 if isinstance(e, Basic):
  return e.count(Basic)
 elif iterable(e):
  return (1 + sum((_nodes(ei) for ei in e)))
 elif isinstance(e, dict):
  return (1 + sum(((_nodes(k) + _nodes(v)) for (k, v) in e.items())))
 else:
  return 1

def _nodes ( e ) : from . basic import Basic if isinstance ( e , Basic ) : return e . count ( Basic ) elif iterable ( e ) : return ( 1 + sum ( ( _nodes ( ei ) for ei in e ) ) ) elif isinstance ( e , dict ) : return ( 1 + sum ( ( ( _nodes ( k ) + _nodes ( v ) ) for ( k , v ) in e . items ( ) ) ) ) else : return 1
a helper for ordered() which returns the node count of e which for basic objects is the number of basic nodes in the expression tree but for other objects is 1 .