private static List <GameObject> FindStartBag(string body, HttpListenerResponse response) { FindBody findBody = ParseFindElementBody(body, response); if (findBody == null) { return(null); } var steps = parser.Parse(findBody.selector); var step = steps [0]; Type type = parser.FindType(step.TagName); if (type == null) { //no type, we need to return an empty result test return(new List <GameObject>()); } var tmpList = GameObject.FindObjectsOfType(type); List <GameObject> rootBag = new List <GameObject> (); //we need only root objects for this foreach (var obj in tmpList) { Component comp = obj as Component; if (comp == null) { continue; } if (step.IsChild == true) { if (comp.gameObject.transform.parent == null) { rootBag.Add(comp.gameObject); } } else { rootBag.Add(comp.gameObject); } } return(rootBag); }