Return a list of all rooted subtrees (each as a list of Location objects).
774683
def get_all_rooted_subtrees_as_lists(self, start_location=None):
        """"""
        if start_location is not None and start_location not in self._location_to_children:
            raise AssertionError(u'Received invalid start_location {} that was not present '
                                 u'in the tree. Present root locations of complex @optional '
                                 u'queries (ones that expand vertex fields within) are: {}'
                                 .format(start_location, self._location_to_children.keys()))

        if start_location is None:
            start_location = self._root_location

        if len(self._location_to_children[start_location]) == 0:
            # Node with no children only returns a singleton list containing the null set.
            return [[]]

        current_children = sorted(self._location_to_children[start_location])

        # Recursively find all rooted subtrees of each of the children of the current node.
        location_to_list_of_subtrees = {
            location: list(self.get_all_rooted_subtrees_as_lists(location))
            for location in current_children
        }

        # All subsets of direct child Location objects
        all_location_subsets = [
            list(subset)
            for subset in itertools.chain(*[
                itertools.combinations(current_children, x)
                for x in range(0, len(current_children) + 1)
            ])
        ]

        # For every possible subset of the children, and every combination of the chosen
        # subtrees within, create a list of subtree Location lists.
        new_subtrees_as_lists = []
        for location_subset in all_location_subsets:
            all_child_subtree_possibilities = [
                location_to_list_of_subtrees[location]
                for location in location_subset
            ]
            all_child_subtree_combinations = itertools.product(*all_child_subtree_possibilities)

            for child_subtree_combination in all_child_subtree_combinations:
                merged_child_subtree_combination = list(itertools.chain(*child_subtree_combination))
                new_subtree_as_list = location_subset + merged_child_subtree_combination
                new_subtrees_as_lists.append(new_subtree_as_list)

        return new_subtrees_as_lists
1251275
public List<Node> searchSubtree(Dn parent) throws NoSuchNodeException, MissingParentException {
        SearchCursor cursor = searchOneLevel(parent);
        return extractNodesFromCursor(cursor);
    }
376475
def fixed(self):
    """"""
    for key, child in self._root.children.items():
      if key == '^':
        return list(child.subpatterns())
    return []
1061177
def children(self) :
        ""
        if not self.isdir() : raise Exception("FSQuery tried to return the children of a node which is not a directory : %s" % self.abs)
        return [FSNode(self.abs + "/" + x,self.root,self.depth+1) for x in os.listdir(self.abs)]
1255539
def build_subtree_strut(self, result, *args, **kwargs):
        
        items = list(result)
        root_elem = {"node": None, "children": OrderedDict()}
        if len(items) == 0:
            return root_elem
        for _, node in enumerate(items):
            new_elem = {"node": node.Resource, "children": OrderedDict()}
            path = list(map(int, node.path.split("/")))
            parent_node = root_elem
            normalized_path = path[:-1]
            if normalized_path:
                for path_part in normalized_path:
                    parent_node = parent_node["children"][path_part]
            parent_node["children"][new_elem["node"].resource_id] = new_elem
        return root_elem
764882
def getAllNodeUids(self):
        '''
            
        '''
        ret = set()

        for child in self:
            ret.update(child.getAllNodeUids())

        return ret
266121
function allNodesAtLocation(location) {
        var nodes = [];
        exports.root.each(function each(n) {
            if (n.type === DOMNode.TYPE_ELEMENT && n.isAtLocation(location)) {
                nodes.push(n);
            }
        });
        return nodes;
    }
446870
def get_modules(root_path):
    """"""
    for dir_path, dir_names, file_names in os.walk(root_path):
        assert dir_path[:len(root_path)] == root_path
        subdir_path = dir_path[len(root_path):]
        package_parts = list(filter(lambda x: x, subdir_path.split('/')))
        for name in file_names:
            if name.endswith('.py'):
                path = os.path.join(dir_path, name)
                pkgpath = '.'.join(package_parts)
                modpath = (pkgpath if name == '__init__.py' else
                           '.'.join(package_parts + [name[:-3]]))
                try:
                    node = ast.parse(open(path).read())
                except SyntaxError:
                    print('ERROR: Invalid syntax in %s' % path, file=sys.stderr)
                else:
                    yield (pkgpath, modpath, path, node)
432106
def getcoordinates(self, tree, location):
        """"""
        return tuple(float(x) for x in tree.xpath('.//%s/*/text()' % location))
89352
def get_paths(self):
        
        paths = []
        for key, child in six.iteritems(self):
            if isinstance(child, TreeMap) and child:
                # current child is an intermediate node
                for path in child.get_paths():
                    path.insert(0, key)
                    paths.append(path)
            else:
                # current child is an endpoint
                paths.append([key])
        return paths
105871
def get_subclass_tree(cls, ensure_unique=True):
    """"""
    subclasses = []
    # cls.__subclasses__() fails on classes inheriting from type
    for subcls in type.__subclasses__(cls):
        subclasses.append(subcls)
        subclasses.extend(get_subclass_tree(subcls, ensure_unique))
    return list(set(subclasses)) if ensure_unique else subclasses
559650
private List<Location> getAllSubLocations(Location location) {
		List<Location> flatSubLocations = new ArrayList<Location>();
		for (Location l : location.getSubLocations()) {
			if (l.isComplex()) {
				flatSubLocations.addAll(getAllSubLocations(l));
			}
			else {
				flatSubLocations.add(l);
			}
		}
		return flatSubLocations;
	}
817601
function getAllRootNodesInTree(tree) {
	let ids = [];

	const rootNodes = axe.utils
		.querySelectorAllFilter(tree, '*', node => {
			if (ids.includes(node.shadowId)) {
				return false;
			}
			ids.push(node.shadowId);
			return true;
		})
		.map(node => {
			return {
				shadowId: node.shadowId,
				rootNode: axe.utils.getRootNode(node.actualNode)
			};
		});

	return axe.utils.uniqueArray(rootNodes, []);
}
495715
def _get_sub_dirs(parent):
    """"""
    return [child for child in os.listdir(parent) if os.path.isdir(os.path.join(parent, child))]
1284810
def as_tree(self):
        ""
        if self._nodes is None:
            return [self]
        ret = [self]
        for node in self._nodes:
            ret.append(node.as_tree())
        return ret
415055
def get_roots(app=None):
    '''
    
    '''
    roots = set()
    plugins = app.config['PLUGINS'] if app else None
    for name in ENTRYPOINTS.keys():
        for ep in iter_all(name):
            if plugins is None or ep.name in plugins:
                roots.add(ep.module_name.split('.', 1)[0])
    return list(roots)
1022355
def _format_subtree(self, subtree):
        """"""
        subtree['children'] = list(subtree['children'].values())
        for child in subtree['children']:
            self._format_subtree(child)
        return subtree