Code dissemination is an important and challenging task in wireless sensor networks (WSNs). Although there are a lot of dissemination protocols, the situation where small subset of nodes requires the code, such as a WSN shared among multiple users, is not considered. Some prior works have proposed dissemination protocols using high power sensors or clustering to enable efficient dissemination for a small subset of sensors with low transmission cost. However, the high power sensors or cluster heads incur the congestion around or between these nodes and the increase of the energy consumption. In this paper, we propose an efficient tree-based code dissemination and search protocol which enables to disseminate a code to small subsets without high power sensors and cluster heads. The protocol is based on an idea that the source only disseminates the code along the route in which the largest number of destinations are located and the rest of destinations obtains the code from the former destinations. Since the most of destinations obtains the code along a single route and a destination has the way to obtain the code by itself, energy consumption is mitigated and 100% packet receive ratio is guaranteed. We employ a standard routing protocol RPL (Routing Protocol for Low-Power and Lossy Networks) for the base of our proposed scheme. We evaluate the proposed scheme and compare with two conventional schemes which enable the dissemination for small subset of sensors. Our simulations show that our proposed scheme reduces the transmission count by 80% and enables to avoid the congestion compared with the conventional schemes.