code: def construct_optional_traversal_tree(complex_optional_roots, location_to_optional_roots):
      
      tree = OptionalTraversalTree(complex_optional_roots)
      for optional_root_locations_stack in six.itervalues(location_to_optional_roots):
          tree.insert(list(optional_root_locations_stack))
  
      return tree
docs: Return a tree of complex optional root locations.
  
      Args:
          complex_optional_roots: list of @optional locations (location immmediately preceding
                                  an @optional Traverse) that expand vertex fields
          location_to_optional_roots: dict mapping from location -> optional_roots where location is
                                      within some number of @optionals and optional_roots is a list
                                      of optional root locations preceding the successive @optional
                                      scopes within which the location resides
  
      Returns:
          OptionalTraversalTree object representing the tree of complex optional roots