internal List <GremlinVariable> Select(string label, GremlinVariable stopVariable = null) { List <GremlinVariable> taggedVariableList = ParentContext?.Select(label, HomeVariable); if (taggedVariableList == null) { taggedVariableList = new List <GremlinVariable>(); } var stopIndex = stopVariable == null ? VariableList.Count : VariableList.IndexOf(stopVariable); for (var i = 0; i < stopIndex; i++) { if (VariableList[i].Labels.Contains(label)) { taggedVariableList.Add(new GremlinContextVariable(VariableList[i])); } else { if (VariableList[i].ContainsLabel(label)) { List <GremlinVariable> subContextVariableList = VariableList[i].PopulateAllTaggedVariable(label); foreach (var subContextVar in subContextVariableList) { if (subContextVar is GremlinGhostVariable) { var ghostVar = subContextVar as GremlinGhostVariable; var newGhostVar = GremlinGhostVariable.Create(ghostVar.RealVariable, ghostVar.AttachedVariable, label); taggedVariableList.Add(newGhostVar); } else { GremlinGhostVariable newVariable = GremlinGhostVariable.Create(subContextVar, VariableList[i], label); taggedVariableList.Add(newVariable); } } } } } return(taggedVariableList); }