def _merge_entries(path, tree1, tree2):
 entries1 = _tree_entries(path, tree1)
 entries2 = _tree_entries(path, tree2)
 i1 = i2 = 0
 len1 = len(entries1)
 len2 = len(entries2)
 result = []
 while ((i1 < len1) and (i2 < len2)):
  entry1 = entries1[i1]
  entry2 = entries2[i2]
  if (entry1.path < entry2.path):
   result.append((entry1, _NULL_ENTRY))
   i1 += 1
  elif (entry1.path > entry2.path):
   result.append((_NULL_ENTRY, entry2))
   i2 += 1
  else:
   result.append((entry1, entry2))
   i1 += 1
   i2 += 1
 for i in range(i1, len1):
  result.append((entries1[i], _NULL_ENTRY))
 for i in range(i2, len2):
  result.append((_NULL_ENTRY, entries2[i]))
 return result

def _merge_entries ( path , tree1 , tree2 ) : entries1 = _tree_entries ( path , tree1 ) entries2 = _tree_entries ( path , tree2 ) i1 = i2 = 0 len1 = len ( entries1 ) len2 = len ( entries2 ) result = [ ] while ( ( i1 < len1 ) and ( i2 < len2 ) ) : entry1 = entries1 [ i1 ] entry2 = entries2 [ i2 ] if ( entry1 . path < entry2 . path ) : result . append ( ( entry1 , _NULL_ENTRY ) ) i1 += 1 elif ( entry1 . path > entry2 . path ) : result . append ( ( _NULL_ENTRY , entry2 ) ) i2 += 1 else : result . append ( ( entry1 , entry2 ) ) i1 += 1 i2 += 1 for i in range ( i1 , len1 ) : result . append ( ( entries1 [ i ] , _NULL_ENTRY ) ) for i in range ( i2 , len2 ) : result . append ( ( _NULL_ENTRY , entries2 [ i ] ) ) return result
merge the entries of two trees .