The “Return Directive”, with implementation deadline of 24 December 2010, sets up a common set of rules for the return of non-EU nationals who do not or who no longer fulfil the conditions for entry, stay or residence within the territory of any EU country, and the related procedural safeguards. It establishes a legal obligation for Member States to take due account of the best interests of the child (Article 5) and to use immigration detention of children and families only as a measure of last resort and for the shortest appropriate period of time (Articles 15 and 17).
https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=celex:32008L0115