Python 3 Solution using BFS
The Idea behind this is to \nStep 1 :\nGet all the trees from a matrix in sorted order. \nStep 2 :\nThen for every tree let\'s know how many number of steps it 
The Idea behind this is to \n**Step 1 :**\nGet all the trees from a matrix in sorted order. \n**Step 2 :**\nThen for every tree let\'s know how many number of steps it takes from the previous node\n(Initially for first tree we will start from (0,0)) \nIf steps < 0 then we are unable to move further due to obstacle so return -1 else add these steps to the totalSteps. \n**Step 3 :**\nIn order to get steps we use bfs \n\nThanks to @CrisaGazzola for video explanation.\nReference : https://youtu.be/HlBnTBLOPOw\n\n```class Solution:\n    def cutOffTree(self, forest: List[List[int]]) -> int:\n        noOfRows = len(forest)\n        noOfColumns = len(forest[0])\n\t\t\n\t\t#step 1 \n\t\t\n        trees = [ (forest[i][j], i, j) for i in range(noOfRows) for j in range(noOfColumns) if forest[i][j] > 1 ]\n        trees = sorted(trees)\n\t\t\n\t\t#Implementation of step 3 BFS\n\t\t\n        def bfs(row,col,treeX,treeY) :\n            visited = [ [False for j in range(noOfColumns)] for i in range(noOfRows)]\n            queue = deque([])\n            queue.append( (row,col,0) )\n            while queue :\n                currX,currY,currSteps = queue.popleft()\n                if (currX == treeX) and (currY == treeY) :\n                    return currSteps \n                for r,c in [ (currX + 1,currY), (currX - 1,currY), (currX,currY + 1), (currX,currY - 1) ] :  \n                    if (r >= 0) and (r < noOfRows) and (c >= 0) and (c < noOfColumns) and (not visited[r][c]) and (forest[r][c] > 0) :\n                        visited[r][c] = True \n                        queue.append( ( r, c, currSteps + 1)  )\n            return -1 \n        \n        x = 0\n        y = 0 \n        totalSteps = 0 \n\t\t\n\t\t#step 2 \n\t\t\n        for tree in trees :\n            steps = bfs(x,y,tree[1],tree[2]) #step 3 \n            if steps < 0 :\n                return -1 \n            totalSteps += steps \n            x = tree[1]\n            y = tree[2]\n            \n        return totalSteps \n```\n
[]