class_docstr: !
  @brief KD-tree visualizer that provides service to display graphical representation of the tree using
          `matplotlib` library.
  @details The visualizer is able to visualize 2D KD-trees only.
  
  There is an example how to visualize balanced KD-tree for `TwoDiamonds` sample using `kdtree_visualizer`:
  @code
      from pyclustering.container.kdtree import kdtree_balanced, kdtree_visualizer
      from pyclustering.utils import read_sample
      from pyclustering.samples.definitions import FCPS_SAMPLES
  
      sample = read_sample(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS)
      tree_instance = kdtree_balanced(sample)
  
      kdtree_visualizer(tree_instance).visualize()
  @endcode
  
  Output result of the example above (balanced tree) - figure 1:
  @image html kd_tree_unbalanced_two_diamonds.png "Fig. 1. Balanced KD-tree for sample 'TwoDiamonds'."
  
  There is one more example to demonstrate unbalanced KD-tree. `kdtree` class is child class of `kdtree_balanced`
  that allows to add points step by step and thus an unbalanced KD-tree can be built.
  @code
      from pyclustering.container.kdtree import kdtree, kdtree_visualizer
      from pyclustering.utils import read_sample
      from pyclustering.samples.definitions import FCPS_SAMPLES
  
      sample = read_sample(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS)
      tree_instance = kdtree()    # Do not use sample in constructor to avoid building of balanced tree.
  
      # Fill KD-tree step by step to obtain unbalanced tree.
      for point in sample:
          tree_instance.insert(point)
  
      kdtree_visualizer(tree_instance).visualize()
  @endcode
  
  Output result of the example above (unbalanced tree) - figure 2:
  @image html kd_tree_unbalanced_two_diamonds.png "Fig. 2. Unbalanced KD-tree for sample 'TwoDiamonds'."
class_docstr_tok: ["!","@","brief","KD-tree","visualizer","that","provides","service","to","display","graphical","representation","of","the","tree","using","`","matplotlib","`","library",".","@","details","The","visualizer","is","able","to","visualize","2D","KD-trees","only",".","There","is","an","example","how","to","visualize","balanced","KD-tree","for","`","TwoDiamonds","`","sample","using","`","kdtree_visualizer","`",":","@","code","from","pyclustering.container.kdtree","import","kdtree_balanced",",","kdtree_visualizer","from","pyclustering.utils","import","read_sample","from","pyclustering.samples.definitions","import","FCPS_SAMPLES","sample","=","read_sample","(","FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS",")","tree_instance","=","kdtree_balanced","(","sample",")","kdtree_visualizer","(","tree_instance",")",".visualize","(",")","@","endcode","Output","result","of","the","example","above","(","balanced","tree",")","-","figure","1",":","@","image","html","kd_tree_unbalanced_two_diamonds.png","``","Fig",".","1",".","Balanced","KD-tree","for","sample","'TwoDiamonds","'",".","''","There","is","one","more","example","to","demonstrate","unbalanced","KD-tree",".","`","kdtree","`","class","is","child","class","of","`","kdtree_balanced","`","that","allows","to","add","points","step","by","step","and","thus","an","unbalanced","KD-tree","can","be","built",".","@","code","from","pyclustering.container.kdtree","import","kdtree",",","kdtree_visualizer","from","pyclustering.utils","import","read_sample","from","pyclustering.samples.definitions","import","FCPS_SAMPLES","sample","=","read_sample","(","FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS",")","tree_instance","=","kdtree","(",")","#","Do","not","use","sample","in","constructor","to","avoid","building","of","balanced","tree",".","#","Fill","KD-tree","step","by","step","to","obtain","unbalanced","tree",".","for","point","in","sample",":","tree_instance.insert","(","point",")","kdtree_visualizer","(","tree_instance",")",".visualize","(",")","@","endcode","Output","result","of","the","example","above","(","unbalanced","tree",")","-","figure","2",":","@","image","html","kd_tree_unbalanced_two_diamonds.png","``","Fig",".","2",".","Unbalanced","KD-tree","for","sample","'TwoDiamonds","'",".","''"]
code: def __get_all_nodes(self):
      nodes = []
  
      next_level = [self.__tree.get_root()]
  
      while len(next_level) != 0:
          cur_level = next_level
          nodes += next_level
          next_level = []
  
          for cur_node in cur_level:
              children = cur_node.get_children()
              if children is not None:
                  next_level += children
  
      return nodes
  
imports: import numpy
  import matplotlib.pyplot
  from pyclustering.utils import euclidean_distance_square, find_left_element
label_desc: Use image node_id 6 for calling the kdtree_visualizer obj's underlying member method code with example usage: obj.__get_all_nodes() and returns: nodes