Routing in wireless sensor networks is one of the main challenges which directly influences the reliability and efficiency of the network. In this research, we combined several flows using inter-coding technique and hierarchical tree alternative path (HTAP) technique in order to efficiently control the congestion. It uses random network coding idea to increases network efficiency and decreases the congestion implicitly. Also, it explicitly reroutes the congested flows along alternative paths when the congestion condition is detected in congested nodes. The proposed method was simulated in different scenarios using MATLAB software and the simulation results showed that it decreases the number of transmitted packets, improves efficiency, and decreases energy consumption in comparison to original HTAP.