Consider a Nest structure according to the picture.
Then create a query to find film titles together with its year directed by Christopher Nolan:
var qTitleSimple = new Simple<string>(); // leave empty for querying all matching values
var qTitle = new Part("Title").Add(qTitleSimple);
var qName2 = new Part("Name").Add(new Simple<string>("Christopher Nolan")); // The Simple to be matched
var qDirector2 = new Part("Director").Add(qName2);
var qYearSimple = new Simple<int>(); // leave empty for querying all matching values
var qYear = new Part("Year").Add(qYearSimple);
var qFilm = new Part("Film").Add(qTitle).Add(qDirector2).Add(qYear);
nest.Query(qFilm);
var yearResults = qYearSimple.GetMatches().ToArray();
var titleResults = qTitleSimple.GetMatches().ToArray();
Console.WriteLine("Query result:");
for (int i = 0; i < yearResults.Length; i++)
{
Console.WriteLine( $"Title: {titleResults[i]} Year: {yearResults[i]}");
}
//------------------------
// Standard Output:
// Query result:
// Title: Inception, Year: 2010
// Title: Memento, Year: 2001
It is possible to add new, or queried, children to another queried structure. The only requirement is that the part of the structure where the child is to be added is uniquely determined. That is if the parent, or any other child of the parent, has the state QueriedUniqueHit or Owned.
For example, the birth year can be added as a child to the Director, even though it has the state QueriedMultipleHits from the query above. Here this is possible since its intended sibling, "Name", has the state QueriedUniqueHit. I.e. all hits to the Director query (2 of them) refers to the same "Name" instance.
var qYearOfBirth = new Part("YearOfBirth").Add(new Simple<int>().AddValue(1970));
qDirector2.Add(qYearOfBirth);
nest.Store(qDirector2);