This paper presents a general algorithm for solving the dynamic of tree structure robots with rigid and flexible links, active and passive joints, and with a fixed or floating base. The algorithm encompasses in a unified approach both the inverse and direct dynamics. It addresses also the hybrid case where each active joint is considered with known joint torque as in the direct dynamic case, or with known joint acceleration as in the inverse dynamic case. To achieve this goal, we propose an efficient recursive approach based on the generalized Newton–Euler equations of flexible tree-structure systems. This new general hybrid algorithm is easy to program either numerically or using efficient customized symbolic techniques. It is of great interest for studying floating base systems with soft appendages as those currently investigated in soft bio-inspired robotics or when a robotic system has to modify its structure for some particular tasks, such as transforming an active joint into a compliant flexible one, or modifying a task with a floating base into one with fixed base.