'This function returns one or more suitable worker nodes to remove from
the cluster. The criteria for removal are:
1. The node must be a worker node (ie not master)
2. The node must not be running any SGE job
3. The node must have been up for self.kill_after min past the hour
If max_remove is specified up to max_remove nodes will be returned for
removal.'

def _find_nodes_for_removal(self, max_remove=None):

    remove_nodes = []
    for node in self._cluster.running_nodes:
        if ((max_remove is not None) and (len(remove_nodes) >= max_remove)):
            return remove_nodes
        if node.is_master():
            continue
        if self._should_remove(node):
            remove_nodes.append(node)
    return remove_nodes
