support for handling branches

(cherry picked from commit cb0a4279faf45ec3b72f21051e1da0b4aa3f2968)