private AggregationBase GetParentContainer(IQueryNode node, IQueryVisitorContext context) { AggregationBase container = null; var currentNode = node; while (container == null && currentNode != null) { IQueryNode n = currentNode; container = n.GetAggregation(() => { var result = n.GetDefaultAggregation(context); if (result != null) { n.SetAggregation(result); } return(result); }) as AggregationBase; if (currentNode.Parent != null) { currentNode = currentNode.Parent; } else { break; } } if (container == null) { container = new ChildrenAggregation(null, null); currentNode.SetAggregation(container); } return(container); }