code: def check_neighbors(self, start, end, grid, open_list,
                          open_value=True, backtrace_by=None):
          
          # pop node with minimum 'f' value
          node = heapq.nsmallest(1, open_list)[0]
          open_list.remove(node)
          node.closed = True
  
          # if reached the end position, construct the path and return it
          # (ignored for bi-directional a*, there we look for a neighbor that is
          #  part of the oncoming path)
          if not backtrace_by and node == end:
              return backtrace(end)
  
          # get neighbors of the current node
          neighbors = self.find_neighbors(grid, node)
          for neighbor in neighbors:
              if neighbor.closed:
                  # already visited last minimum f value
                  continue
              if backtrace_by and neighbor.opened == backtrace_by:
                  # found the oncoming path
                  if backtrace_by == BY_END:
                      return bi_backtrace(node, neighbor)
                  else:
                      return bi_backtrace(neighbor, node)
  
              # check if the neighbor has not been inspected yet, or
              # can be reached with smaller cost from the current node
              self.process_node(neighbor, node, end, open_list, open_value)
  
          # the end has not been reached (yet) keep the find_path loop running
          return None
docs: find next path segment based on given node
          (or return path if we found the end)