def select_direct_adjacent(cache, left, right):
 right = (always_in if (right is None) else frozenset(right))
 for parent in left:
  for sibling in cache.itersiblings(parent):
   if (sibling in right):
    (yield sibling)
   break

def select_direct_adjacent ( cache , left , right ) : right = ( always_in if ( right is None ) else frozenset ( right ) ) for parent in left : for sibling in cache . itersiblings ( parent ) : if ( sibling in right ) : ( yield sibling ) break
right is a sibling immediately after left .